diff --git a/sdk/nodejs/.gitignore b/sdk/nodejs/.gitignore index c6bf92ac5..7c3df689f 100644 --- a/sdk/nodejs/.gitignore +++ b/sdk/nodejs/.gitignore @@ -4,3 +4,4 @@ /node_modules/ /custom_node/ /runtime/native/node_dev/ +.nyc_output/ diff --git a/sdk/nodejs/Makefile b/sdk/nodejs/Makefile index a26205e57..ac27b949f 100644 --- a/sdk/nodejs/Makefile +++ b/sdk/nodejs/Makefile @@ -46,25 +46,28 @@ install_plugin:: build install:: install_package install_plugin -istanbul_tests:: $(TEST_ALL_DEPS) - $(RUN_TESTSUITE) istanbul ./node_modules/.bin/istanbul test --print none _mocha -- --timeout 120000 --exclude 'bin/tests/automation/**/*.spec.js' 'bin/tests/**/*.spec.js' - ./node_modules/.bin/istanbul report text-summary - ./node_modules/.bin/istanbul report text - $(RUN_TESTSUITE) istanbul-with-mocks ./node_modules/.bin/istanbul test --print none _mocha -- 'bin/tests_with_mocks/**/*.spec.js' +unit_tests:: $(TEST_ALL_DEPS) + $(RUN_TESTSUITE) unit-nodejs ./node_modules/.bin/nyc -x 'bin/tests/runtime/*ClosureCases*.js' -s mocha --timeout 120000 --exclude 'bin/tests/automation/**/*.spec.js' --exclude 'bin/tests/runtime/closureLoader.spec.js' 'bin/tests/**/*.spec.js' + $(RUN_TESTSUITE) unit-nodejs mocha --timeout 120000 'bin/tests/runtime/closureLoader.spec.js' + $(RUN_TESTSUITE) unit-with-mocks-nodejs ./node_modules/.bin/nyc -s mocha 'bin/tests_with_mocks/**/*.spec.js' auto_tests:: $(TEST_ALL_DEPS) - $(RUN_TESTSUITE) auto-nodejs ./node_modules/.bin/istanbul test --print none _mocha -- --timeout 120000 'bin/tests/automation/**/*.spec.js' - ./node_modules/.bin/istanbul report text-summary - ./node_modules/.bin/istanbul report text + $(RUN_TESTSUITE) auto-nodejs ./node_modules/.bin/nyc -s mocha --timeout 120000 'bin/tests/automation/**/*.spec.js' sxs_tests:: $(TEST_ALL_DEPS) pushd tests/sxs_ts_3.6 && yarn ; tsc ; popd pushd tests/sxs_ts_latest && yarn ; tsc ; popd -test_fast:: sxs_tests istanbul_tests +test_fast:: sxs_tests unit_tests +ifneq ($(PULUMI_TEST_COVERAGE_PATH),) + if [ -e .nyc_output ]; then ./node_modules/.bin/nyc report -r cobertura --report-dir $(PULUMI_TEST_COVERAGE_PATH); fi +endif $(GO_TEST_FAST) ${PROJECT_PKGS} -test_all:: sxs_tests istanbul_tests auto_tests +test_all:: sxs_tests unit_tests auto_tests +ifneq ($(PULUMI_TEST_COVERAGE_PATH),) + if [ -e .nyc_output ]; then ./node_modules/.bin/nyc report -r cobertura --report-dir $(PULUMI_TEST_COVERAGE_PATH); fi +endif $(GO_TEST) ${PROJECT_PKGS} dist:: build diff --git a/sdk/nodejs/package.json b/sdk/nodejs/package.json index a832982dd..5d8c90f95 100644 --- a/sdk/nodejs/package.json +++ b/sdk/nodejs/package.json @@ -39,13 +39,16 @@ "eslint": "^7.32.0", "eslint-plugin-header": "^3.1.1", "eslint-plugin-import": "^2.23.4", - "istanbul": "^0.4.5", - "mocha": "^3.5.0" + "nyc": "^15.1.0", + "mocha": "^9.0.0" }, "pulumi": { "comment": "Do not remove. Marks this as as a deployment-time-only package" }, "engines": { "node": ">=8.13.0 || >=10.10.0" + }, + "mocha": { + "require": ["ts-node/register", "source-map-support/register"] } } diff --git a/sdk/nodejs/tsconfig.json b/sdk/nodejs/tsconfig.json index 33369f709..e200f468a 100644 --- a/sdk/nodejs/tsconfig.json +++ b/sdk/nodejs/tsconfig.json @@ -6,7 +6,7 @@ "module": "commonjs", "moduleResolution": "node", "declaration": true, - "sourceMap": false, + "sourceMap": true, "stripInternal": true, "experimentalDecorators": true, "pretty": true,