From f60f3e0a9d7d6d71d2beb109c6fb08f6f31b852e Mon Sep 17 00:00:00 2001 From: gurke Date: Tue, 12 Nov 2024 09:32:01 +0100 Subject: [PATCH] test: improved local test running (#1441) - Added node script to add terminal aliases (helps to easily run test groups) - Integrated mocha watch - Removed redundant sh helper scripts - See https://github.com/mochajs/mocha/issues/5149 --------- Co-authored-by: Arya <90748009+aryamohanan@users.noreply.github.com> --- CONTRIBUTING.md | 26 ++++++-- bin/add-test-aliases.js | 62 +++++++++++++++++++ bin/run-autoprofile-tests.sh | 11 ---- bin/run-aws-lambda-auto-wrap.sh | 10 --- bin/run-azure-container-services-tests.sh | 9 --- bin/run-collector-tests.sh | 11 ---- bin/run-core-tests.sh | 11 ---- bin/run-fargate-tests.sh | 11 ---- bin/run-google-cloud-run-tests.sh | 11 ---- bin/run-lambda-tests.sh | 11 ---- bin/run-metrics-util-tests.sh | 11 ---- bin/run-otel-exporter-tests.sh | 11 ---- bin/run-otel-sampler-tests.sh | 9 --- bin/run-serverless-collector-tests.sh | 10 --- bin/run-serverless-tests.sh | 11 ---- bin/run-shared-metrics-tests.sh | 11 ---- bin/run-tests.sh | 29 ++++++++- packages/autoprofile/package.json | 2 +- packages/aws-fargate/package.json | 2 +- packages/aws-lambda-auto-wrap/package.json | 2 +- packages/aws-lambda/package.json | 2 +- .../azure-container-services/package.json | 2 +- packages/collector/package.json | 2 +- .../collector/test/apps/agentStubControls.js | 3 + packages/collector/test/hooks.js | 19 +++++- packages/core/package.json | 2 +- packages/google-cloud-run/package.json | 2 +- packages/metrics-util/package.json | 2 +- packages/opentelemetry-exporter/package.json | 2 +- packages/opentelemetry-sampler/package.json | 2 +- packages/serverless-collector/package.json | 2 +- packages/serverless/package.json | 2 +- packages/shared-metrics/package.json | 2 +- 33 files changed, 145 insertions(+), 170 deletions(-) create mode 100644 bin/add-test-aliases.js delete mode 100755 bin/run-autoprofile-tests.sh delete mode 100755 bin/run-aws-lambda-auto-wrap.sh delete mode 100755 bin/run-azure-container-services-tests.sh delete mode 100755 bin/run-collector-tests.sh delete mode 100755 bin/run-core-tests.sh delete mode 100755 bin/run-fargate-tests.sh delete mode 100755 bin/run-google-cloud-run-tests.sh delete mode 100755 bin/run-lambda-tests.sh delete mode 100755 bin/run-metrics-util-tests.sh delete mode 100755 bin/run-otel-exporter-tests.sh delete mode 100755 bin/run-otel-sampler-tests.sh delete mode 100755 bin/run-serverless-collector-tests.sh delete mode 100755 bin/run-serverless-tests.sh delete mode 100755 bin/run-shared-metrics-tests.sh diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2d780dc7cd..7f152d02d3 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -26,15 +26,33 @@ Install the [`aws-cli`](https://docs.aws.amazon.com/cli/latest/userguide/getting ## Executing Tests Locally -Some of the tests require infrastructure components (databases etc.) to run locally. The easiest way to run all required components locally is to use Docker and on top of this [Docker Compose](https://docs.docker.com/compose/). Start the script `node bin/start-test-containers.js` to run all containers (not recommended). - -Instead: +Some of the tests require infrastructure components (databases etc.) to run locally. The easiest way to run required components locally is to use Docker and on top of this [Docker Compose](https://docs.docker.com/compose/). ```sh node bin/start-test-containers.js --mongo --redis ``` -It's not recommended to run all tests using `bin/run-tests.sh` - it takes too long. Take a look at the root package.json and run a specific test group or run e.g. `bin/run-collector-tests.sh` with the mocha `.only` attribute. +### Using terminal aliases + +Add aliases to your terminal: + +```sh +node bin/add-test-aliases.js bash|zsh +``` + +Add a mocha `.only` on the test you would like to execute and then run the target scope: + +```sh +runcollector # Run the 'collector' scope with watch mode +runcollector-nw # Run the 'collector' scope without watch mode +``` + +### Manually + +```sh +bin/run-tests.sh --scope=@instana/collector +bin/run-tests.sh --scope=@instana/collector --watch +``` If you want to see the Node.js collector's debug output while running the tests, make sure the environment variable `WITH_STDOUT` is set to a non-empty string. diff --git a/bin/add-test-aliases.js b/bin/add-test-aliases.js new file mode 100644 index 0000000000..610d9e186a --- /dev/null +++ b/bin/add-test-aliases.js @@ -0,0 +1,62 @@ +/* + * (c) Copyright IBM Corp. 2024 + */ + +'use strict'; + +const { execSync } = require('child_process'); +const fs = require('fs'); +const os = require('os'); + +const addAliasIfNotExists = (aliasCommand, configFile) => { + let fileContent = ''; + try { + fileContent = fs.readFileSync(configFile, 'utf8'); + } catch (err) { + console.error(`Could not read ${configFile}: ${err.message}`); + return; + } + + if (!fileContent.includes(aliasCommand)) { + fs.appendFileSync(configFile, `\n${aliasCommand}\n`); + console.log(`Added alias: ${aliasCommand}`); + } else { + console.log(`Alias already exists: ${aliasCommand}`); + } +}; + +const output = execSync('lerna list --json', { encoding: 'utf-8' }); +const packages = JSON.parse(output); +const scopeNames = packages.map(pkg => pkg.name); +const shellArg = process.argv[2]; + +if (!shellArg) { + console.error('Error: Please specify either "bash" or "zsh".'); + process.exit(1); +} + +let configFile; +if (shellArg === 'bash') { + configFile = `${os.homedir()}/.bashrc`; +} else if (shellArg === 'zsh') { + configFile = `${os.homedir()}/.zshrc`; +} else { + console.error('Error: Invalid argument. Please specify "bash" or "zsh".'); + process.exit(1); +} + +scopeNames.forEach(scope => { + const cleanedScope = scope.replace('@instana/', ''); + + const watchAlias = `alias run${cleanedScope}='bin/run-tests.sh --scope=${scope} --watch'`; + const nwAlias = `alias run${cleanedScope}-nw='bin/run-tests.sh --scope=${scope}'`; + + addAliasIfNotExists(watchAlias, configFile); + addAliasIfNotExists(nwAlias, configFile); +}); + +console.log('Aliases added. Please run the following command to apply the changes:'); +console.log(` source ${configFile}`); +console.log('Alternatively, restart your terminal.'); + +console.log('Done'); diff --git a/bin/run-autoprofile-tests.sh b/bin/run-autoprofile-tests.sh deleted file mode 100755 index ed4b68c35a..0000000000 --- a/bin/run-autoprofile-tests.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env bash - -####################################### -# (c) Copyright IBM Corp. 2021 -# (c) Copyright Instana Inc. and contributors 2019 -####################################### - -set -eo pipefail - -npx lerna exec "npm run test:debug" --scope=@instana/autoprofile - diff --git a/bin/run-aws-lambda-auto-wrap.sh b/bin/run-aws-lambda-auto-wrap.sh deleted file mode 100755 index bacbde3595..0000000000 --- a/bin/run-aws-lambda-auto-wrap.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env bash - -####################################### -# (c) Copyright IBM Corp. 2022 -####################################### - -set -eo pipefail - -npx lerna exec "npm run test:debug" --scope=instana-aws-lambda-auto-wrap - diff --git a/bin/run-azure-container-services-tests.sh b/bin/run-azure-container-services-tests.sh deleted file mode 100755 index 11967aa551..0000000000 --- a/bin/run-azure-container-services-tests.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bash - -####################################### -# (c) Copyright IBM Corp. 2023 -####################################### - -set -eo pipefail - -npx lerna exec "npm run test:debug" --scope=@instana/azure-container-services \ No newline at end of file diff --git a/bin/run-collector-tests.sh b/bin/run-collector-tests.sh deleted file mode 100755 index 93043c9c6f..0000000000 --- a/bin/run-collector-tests.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env bash - -####################################### -# (c) Copyright IBM Corp. 2021 -# (c) Copyright Instana Inc. and contributors 2018 -####################################### - -set -eo pipefail - -npx lerna exec "npm run test:debug" --scope=@instana/collector - diff --git a/bin/run-core-tests.sh b/bin/run-core-tests.sh deleted file mode 100755 index 144d9417b3..0000000000 --- a/bin/run-core-tests.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env bash - -####################################### -# (c) Copyright IBM Corp. 2021 -# (c) Copyright Instana Inc. and contributors 2019 -####################################### - -set -eo pipefail - -npx lerna exec "npm run test:debug" --scope=@instana/core - diff --git a/bin/run-fargate-tests.sh b/bin/run-fargate-tests.sh deleted file mode 100755 index 54ce4351c0..0000000000 --- a/bin/run-fargate-tests.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env bash - -####################################### -# (c) Copyright IBM Corp. 2021 -# (c) Copyright Instana Inc. and contributors 2019 -####################################### - -set -eo pipefail - -npx lerna exec "npm run test:debug" --scope=@instana/aws-fargate - diff --git a/bin/run-google-cloud-run-tests.sh b/bin/run-google-cloud-run-tests.sh deleted file mode 100755 index 682bbbf1bb..0000000000 --- a/bin/run-google-cloud-run-tests.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env bash - -####################################### -# (c) Copyright IBM Corp. 2021 -# (c) Copyright Instana Inc. and contributors 2019 -####################################### - -set -eo pipefail - -npx lerna exec "npm run test:debug" --scope=@instana/google-cloud-run - diff --git a/bin/run-lambda-tests.sh b/bin/run-lambda-tests.sh deleted file mode 100755 index 94f1099efa..0000000000 --- a/bin/run-lambda-tests.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env bash - -####################################### -# (c) Copyright IBM Corp. 2021 -# (c) Copyright Instana Inc. and contributors 2019 -####################################### - -set -eo pipefail - -npx lerna exec "npm run test:debug" --scope=@instana/aws-lambda - diff --git a/bin/run-metrics-util-tests.sh b/bin/run-metrics-util-tests.sh deleted file mode 100755 index e6384c6acd..0000000000 --- a/bin/run-metrics-util-tests.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env bash - -####################################### -# (c) Copyright IBM Corp. 2021 -# (c) Copyright Instana Inc. and contributors 2019 -####################################### - -set -eo pipefail - -npx lerna exec "npm run test:debug" --scope=@instana/metrics-util - diff --git a/bin/run-otel-exporter-tests.sh b/bin/run-otel-exporter-tests.sh deleted file mode 100755 index 4286a6cb43..0000000000 --- a/bin/run-otel-exporter-tests.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env bash - -####################################### -# (c) Copyright IBM Corp. 2021 -# (c) Copyright Instana Inc. and contributors 2019 -####################################### - -set -eo pipefail - -npx lerna exec "npm run test:debug" --scope=@instana/opentelemetry-exporter - diff --git a/bin/run-otel-sampler-tests.sh b/bin/run-otel-sampler-tests.sh deleted file mode 100755 index 3794d9898e..0000000000 --- a/bin/run-otel-sampler-tests.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bash - -####################################### -# (c) Copyright IBM Corp. 2022 -####################################### - -set -eo pipefail - -npx lerna exec "npm run test:debug" --scope=@instana/opentelemetry-sampler \ No newline at end of file diff --git a/bin/run-serverless-collector-tests.sh b/bin/run-serverless-collector-tests.sh deleted file mode 100755 index 55777719f8..0000000000 --- a/bin/run-serverless-collector-tests.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env bash - -####################################### -# (c) Copyright IBM Corp. 2024 -####################################### - -set -eo pipefail - -npx lerna exec "npm run test:debug" --scope=@instana/serverless-collector - diff --git a/bin/run-serverless-tests.sh b/bin/run-serverless-tests.sh deleted file mode 100755 index 8ca661ea63..0000000000 --- a/bin/run-serverless-tests.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env bash - -####################################### -# (c) Copyright IBM Corp. 2021 -# (c) Copyright Instana Inc. and contributors 2019 -####################################### - -set -eo pipefail - -npx lerna exec "npm run test:debug" --scope=@instana/serverless - diff --git a/bin/run-shared-metrics-tests.sh b/bin/run-shared-metrics-tests.sh deleted file mode 100755 index a8d10285b7..0000000000 --- a/bin/run-shared-metrics-tests.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env bash - -####################################### -# (c) Copyright IBM Corp. 2021 -# (c) Copyright Instana Inc. and contributors 2019 -####################################### - -set -eo pipefail - -npx lerna exec "npm run test:debug" --scope=@instana/shared-metrics - diff --git a/bin/run-tests.sh b/bin/run-tests.sh index 5256bd727c..f17dcb04c2 100755 --- a/bin/run-tests.sh +++ b/bin/run-tests.sh @@ -2,10 +2,35 @@ ####################################### # (c) Copyright IBM Corp. 2021 -# (c) Copyright Instana Inc. and contributors 2018 ####################################### set -eo pipefail -npx lerna run test:debug --stream +WATCH=false +SCOPE="" + +for arg in "$@"; do + case $arg in + --watch) + WATCH=true + shift + ;; + --scope=*) + SCOPE="${arg#*=}" + shift + ;; + *) + shift + ;; + esac +done + +if [ "$WATCH" = true ]; then + export npm_config_watch="--watch" +else + export npm_config_watch="" +fi + +echo "Running tests with $SCOPE and $npm_config_watch:" +npx lerna exec --scope="$SCOPE" "npm run test:debug" diff --git a/packages/autoprofile/package.json b/packages/autoprofile/package.json index 06e169df09..f2fc8b76b5 100644 --- a/packages/autoprofile/package.json +++ b/packages/autoprofile/package.json @@ -27,7 +27,7 @@ "audit": "npm audit --omit=dev", "node_modules:exists": "mkdir -p node_modules", "install": "node-gyp-build", - "test": "mocha --config=test/.mocharc.js --require test/hooks.js --sort $(find test -iname '*test.js' -not -path '*node_modules*')", + "test": "mocha $npm_config_watch --config=test/.mocharc.js --require test/hooks.js --sort $(find test -iname '*test.js' -not -path '*node_modules*')", "test:debug": "WITH_STDOUT=true npm run test", "test:ci": "echo \"******* Files to be tested:\n $CI_AUTOPROFILE_TEST_FILES\" && if [ -z \"${CI_AUTOPROFILE_TEST_FILES}\" ]; then echo \"No test files have been assigned to this CircleCI executor.\"; else mocha --config=test/.mocharc.js --reporter mocha-multi-reporters --reporter-options configFile=reporter-config.json --require test/hooks.js --sort ${CI_AUTOPROFILE_TEST_FILES}; fi", "lint": "eslint lib test", diff --git a/packages/aws-fargate/package.json b/packages/aws-fargate/package.json index 5e34a5d0f5..680f5352df 100644 --- a/packages/aws-fargate/package.json +++ b/packages/aws-fargate/package.json @@ -27,7 +27,7 @@ "scripts": { "audit": "npm audit --omit=dev", "node_modules:exists": "mkdir -p node_modules", - "test": "mocha --config=test/.mocharc.js --reporter mocha-multi-reporters --reporter-options configFile=reporter-config.json --sort $(find test -iname '*test.js')", + "test": "mocha $npm_config_watch --config=test/.mocharc.js --reporter mocha-multi-reporters --reporter-options configFile=reporter-config.json --sort $(find test -iname '*test.js')", "test:debug": "WITH_STDOUT=true npm run test", "test:ci": "mocha --config=test/.mocharc.js --reporter mocha-multi-reporters --reporter-options configFile=reporter-config.json 'test/**/*test.js'", "lint": "eslint src test images", diff --git a/packages/aws-lambda-auto-wrap/package.json b/packages/aws-lambda-auto-wrap/package.json index afe1f819b9..62fafa0dd3 100644 --- a/packages/aws-lambda-auto-wrap/package.json +++ b/packages/aws-lambda-auto-wrap/package.json @@ -27,7 +27,7 @@ "scripts": { "audit": "npm audit --omit=dev", "node_modules:exists": "mkdir -p node_modules", - "test": "mocha --config=test/.mocharc.js --sort $(find test -iname '*test.js')", + "test": "mocha $npm_config_watch --config=test/.mocharc.js --sort $(find test -iname '*test.js')", "test:debug": "WITH_STDOUT=true npm run test", "test:ci": "mocha --config=test/.mocharc.js --reporter mocha-multi-reporters --reporter-options configFile=reporter-config.json 'test/**/*test.js'", "lint": "eslint src", diff --git a/packages/aws-lambda/package.json b/packages/aws-lambda/package.json index ffe2a5f72c..9c26e1a03e 100644 --- a/packages/aws-lambda/package.json +++ b/packages/aws-lambda/package.json @@ -27,7 +27,7 @@ "scripts": { "audit": "npm audit --omit=dev", "node_modules:exists": "mkdir -p node_modules", - "test": "mocha --config=test/.mocharc.js --sort $(find test -iname '*test.js')", + "test": "mocha $npm_config_watch --config=test/.mocharc.js --sort $(find test -iname '*test.js')", "test:debug": "WITH_STDOUT=true INSTANA_DEBUG=true npm run test", "test:ci": "mocha --config=test/.mocharc.js --reporter mocha-multi-reporters --reporter-options configFile=reporter-config.json 'test/**/*test.js'", "lint": "eslint src test lambdas", diff --git a/packages/azure-container-services/package.json b/packages/azure-container-services/package.json index 5a43a58389..33e797263d 100644 --- a/packages/azure-container-services/package.json +++ b/packages/azure-container-services/package.json @@ -27,7 +27,7 @@ "scripts": { "audit": "npm audit --omit=dev", "node_modules:exists": "mkdir -p node_modules", - "test": "mocha --sort $(find test -iname '*test.js')", + "test": "mocha $npm_config_watch --config=test/.mocharc.js --sort $(find test -iname '*test.js')", "test:debug": "WITH_STDOUT=true npm run test", "test:ci": "mocha --config=test/.mocharc.js --reporter mocha-multi-reporters --reporter-options configFile=reporter-config.json 'test/**/*test.js'", "lint": "eslint src test images", diff --git a/packages/collector/package.json b/packages/collector/package.json index 578c8e3b80..85d5305b0d 100644 --- a/packages/collector/package.json +++ b/packages/collector/package.json @@ -36,7 +36,7 @@ }, "scripts": { "audit": "npm audit --omit=dev", - "test": "USE_OPENTRACING_DEBUG_IMPL=true mocha --config=test/.mocharc.js --require test/hooks.js --sort $(find test -iname '*test.js')", + "test": "USE_OPENTRACING_DEBUG_IMPL=true mocha $npm_config_watch --config=test/.mocharc.js --require test/hooks.js --sort $(find test -iname '*test.js')", "test:debug": "WITH_STDOUT=true npm run test", "test:ci:general": "mocha --config=test/.mocharc.js --reporter mocha-multi-reporters --reporter-options configFile=reporter-config.json --require test/hooks.js 'test/**/*test.js' --exclude 'test/tracing/**/*test.js'", "test:ci:tracing:frameworks": "mocha --config=test/.mocharc.js --reporter mocha-multi-reporters --reporter-options configFile=reporter-config.json --require test/hooks.js 'test/tracing/frameworks/**/*test.js'", diff --git a/packages/collector/test/apps/agentStubControls.js b/packages/collector/test/apps/agentStubControls.js index 2d59175437..eee7a6c027 100644 --- a/packages/collector/test/apps/agentStubControls.js +++ b/packages/collector/test/apps/agentStubControls.js @@ -162,6 +162,9 @@ class AgentStubControls { } async reset() { + // eslint-disable-next-line no-console + console.log(`[AgentStubControls] reset ${this.agentPort}`); + return retry(async () => { await fetch(`http://127.0.0.1:${this.agentPort}/`, { method: 'DELETE', diff --git a/packages/collector/test/hooks.js b/packages/collector/test/hooks.js index da53944bee..71b4909bb6 100644 --- a/packages/collector/test/hooks.js +++ b/packages/collector/test/hooks.js @@ -10,14 +10,20 @@ // scripts for running tests take care of that. // // The globalAgent module manages an agent stub instance that can be used globally for all tests. - -const { startGlobalAgent, stopGlobalAgent } = require('./globalAgent'); +const path = require('path'); const isCI = require('@instana/core/test/test_util/is_ci'); const config = require('@instana/core/test/config'); const fs = require('fs'); exports.mochaHooks = { async beforeAll() { + // NOTE: mocha --watch has a bug (https://github.com/mochajs/mocha/issues/5149) + // We manually clear the file from the cache here. + const globalAgentModulePath = path.resolve(__dirname, './globalAgent'); + delete require.cache[globalAgentModulePath]; + + const { startGlobalAgent } = require('./globalAgent'); + // eslint-disable-next-line no-console console.log(`@instana/collector test suite starting at ${timestamp()}.`); this.timeout(config.getTestTimeout()); @@ -54,6 +60,15 @@ exports.mochaHooks = { }, async afterAll() { + // NOTE: mocha --watch has a bug (https://github.com/mochajs/mocha/issues/5149) + // We manually clear the file from the cache here. + const globalAgentModulePath = path.resolve(__dirname, './globalAgent'); + delete require.cache[globalAgentModulePath]; + + const { stopGlobalAgent } = require('./globalAgent'); + + // eslint-disable-next-line no-console + console.log(`@instana/collector test suite stopping at ${timestamp()}.`); this.timeout(config.getTestTimeout()); await stopGlobalAgent(); } diff --git a/packages/core/package.json b/packages/core/package.json index ded62f92e9..a161728306 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -13,7 +13,7 @@ }, "scripts": { "audit": "npm audit --omit=dev", - "test": "USE_OPENTRACING_DEBUG_IMPL=true mocha --config=test/.mocharc.js --reporter mocha-multi-reporters --reporter-options configFile=reporter-config.json --sort $(find test -iname '*test.js')", + "test": "USE_OPENTRACING_DEBUG_IMPL=true mocha $npm_config_watch --config=test/.mocharc.js --reporter mocha-multi-reporters --reporter-options configFile=reporter-config.json --sort $(find test -iname '*test.js')", "test:debug": "WITH_STDOUT=true npm run test", "test:ci": "mocha --config=test/.mocharc.js --reporter mocha-multi-reporters --reporter-options configFile=reporter-config.json 'test/**/*test.js'", "lint": "eslint src test", diff --git a/packages/google-cloud-run/package.json b/packages/google-cloud-run/package.json index b92967afda..67add1b6e4 100644 --- a/packages/google-cloud-run/package.json +++ b/packages/google-cloud-run/package.json @@ -28,7 +28,7 @@ "scripts": { "audit": "npm audit --omit=dev", "node_modules:exists": "mkdir -p node_modules", - "test": "mocha --config=test/.mocharc.js --sort $(find test -iname '*test.js')", + "test": "mocha $npm_config_watch --config=test/.mocharc.js --sort $(find test -iname '*test.js')", "test:debug": "WITH_STDOUT=true npm run test", "test:ci": "mocha --config=test/.mocharc.js --reporter mocha-multi-reporters --reporter-options configFile=reporter-config.json 'test/**/*test.js'", "lint": "eslint src test images", diff --git a/packages/metrics-util/package.json b/packages/metrics-util/package.json index 31e7decbdb..e5f7af8db1 100644 --- a/packages/metrics-util/package.json +++ b/packages/metrics-util/package.json @@ -26,7 +26,7 @@ "scripts": { "audit": "npm audit --omit=dev", "node_modules:exists": "mkdir -p node_modules", - "test": "mocha --sort $(find test -iname '*test.js')", + "test": "mocha $npm_config_watch --config=test/.mocharc.js --sort $(find test -iname '*test.js')", "test:debug": "WITH_STDOUT=true npm run test", "test:ci": "mocha --config=test/.mocharc.js --reporter mocha-multi-reporters --reporter-options configFile=reporter-config.json 'test/**/*test.js'", "lint": "eslint src test", diff --git a/packages/opentelemetry-exporter/package.json b/packages/opentelemetry-exporter/package.json index 19b4945220..98c0a762ef 100644 --- a/packages/opentelemetry-exporter/package.json +++ b/packages/opentelemetry-exporter/package.json @@ -31,7 +31,7 @@ "audit": "npm audit --omit=dev", "start": "node test/app.js", "debug": "node --inspect-brk test/app.js", - "test": "WITH_STDOUT=true mocha --config=test/.mocharc.js --sort $(find test -iname '*test.js')", + "test": "WITH_STDOUT=true mocha $npm_config_watch --config=test/.mocharc.js --sort $(find test -iname '*test.js')", "test:debug": "WITH_STDOUT=true npm run test", "test:ci": "mocha --config=test/.mocharc.js --reporter mocha-multi-reporters --reporter-options configFile=reporter-config.json 'test/**/*test.js'", "lint": "eslint src test", diff --git a/packages/opentelemetry-sampler/package.json b/packages/opentelemetry-sampler/package.json index db7bcada02..dd01d77d53 100644 --- a/packages/opentelemetry-sampler/package.json +++ b/packages/opentelemetry-sampler/package.json @@ -31,7 +31,7 @@ "audit": "npm audit --omit=dev", "start": "node test/app.js", "debug": "node --inspect-brk test/app.js", - "test": "mocha --config=test/.mocharc.js --sort $(find test -iname '*test.js')", + "test": "mocha $npm_config_watch --config=test/.mocharc.js --sort $(find test -iname '*test.js')", "test:debug": "WITH_STDOUT=true npm run test", "test:ci": "mocha --config=test/.mocharc.js --reporter mocha-multi-reporters --reporter-options configFile=reporter-config.json 'test/**/*test.js'", "lint": "eslint src test", diff --git a/packages/serverless-collector/package.json b/packages/serverless-collector/package.json index d64e040015..f4f61d05e2 100644 --- a/packages/serverless-collector/package.json +++ b/packages/serverless-collector/package.json @@ -27,7 +27,7 @@ "scripts": { "audit": "npm audit --omit=dev", "node_modules:exists": "mkdir -p node_modules", - "test": "mocha --sort $(find test -iname '*test.js')", + "test": "mocha $npm_config_watch --config=test/.mocharc.js --sort $(find test -iname '*test.js')", "test:debug": "WITH_STDOUT=true npm run test", "test:ci": "mocha --config=test/.mocharc.js --reporter mocha-multi-reporters --reporter-options configFile=reporter-config.json 'test/**/*test.js'", "lint": "eslint src test", diff --git a/packages/serverless/package.json b/packages/serverless/package.json index 0ec3bd1c72..4f38ced0d2 100644 --- a/packages/serverless/package.json +++ b/packages/serverless/package.json @@ -26,7 +26,7 @@ "scripts": { "audit": "npm audit --omit=dev", "node_modules:exists": "mkdir -p node_modules", - "test": "mocha --config=test/.mocharc.js --sort $(find test -iname '*test.js')", + "test": "mocha $npm_config_watch --config=test/.mocharc.js --sort $(find test -iname '*test.js')", "test:ci": "mocha --config=test/.mocharc.js --reporter mocha-multi-reporters --reporter-options configFile=reporter-config.json 'test/**/*test.js'", "test:debug": "WITH_STDOUT=true npm run test", "lint": "eslint src test", diff --git a/packages/shared-metrics/package.json b/packages/shared-metrics/package.json index 64ff4fa65e..3e258bd3ba 100644 --- a/packages/shared-metrics/package.json +++ b/packages/shared-metrics/package.json @@ -26,7 +26,7 @@ }, "scripts": { "audit": "npm audit --omit=dev", - "test": "mocha --config=test/.mocharc.js --require test/hooks.js --sort $(find test -iname '*test.js')", + "test": "mocha $npm_config_watch --config=test/.mocharc.js --require test/hooks.js --sort $(find test -iname '*test.js')", "test:ci": "mocha --config=test/.mocharc.js --reporter mocha-multi-reporters --reporter-options configFile=reporter-config.json --require test/hooks.js 'test/**/*test.js'", "test:debug": "WITH_STDOUT=true npm run test", "lint": "eslint src test",