From 26065ace6daf94cbeea598bac4819b88484093d7 Mon Sep 17 00:00:00 2001 From: Jeremy Meng Date: Fri, 1 May 2020 11:56:51 -0700 Subject: [PATCH] [FormRecognizer] Enable code coverage (#8557) for both NodeJs and browser --- sdk/formrecognizer/ai-form-recognizer/.nycrc | 19 +++++++++++++++++++ .../ai-form-recognizer/karma.conf.js | 4 ++-- .../ai-form-recognizer/package.json | 3 ++- 3 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 sdk/formrecognizer/ai-form-recognizer/.nycrc diff --git a/sdk/formrecognizer/ai-form-recognizer/.nycrc b/sdk/formrecognizer/ai-form-recognizer/.nycrc new file mode 100644 index 000000000000..0ae05d8dba5c --- /dev/null +++ b/sdk/formrecognizer/ai-form-recognizer/.nycrc @@ -0,0 +1,19 @@ +{ + "include": [ + "dist-esm/src/**/*.js" + ], + "exclude": [ + "**/*.d.ts", + "dist-esm/src/utils/utils.browser.js", + "dist-esm/src/generated/src/**/*.js" + ], + "reporter": [ + "text-summary", + "html", + "cobertura" + ], + "exclude-after-remap":false, + "sourceMap": true, + "instrument": true, + "all": true +} diff --git a/sdk/formrecognizer/ai-form-recognizer/karma.conf.js b/sdk/formrecognizer/ai-form-recognizer/karma.conf.js index 7aace85f782e..d3c3911c45ab 100644 --- a/sdk/formrecognizer/ai-form-recognizer/karma.conf.js +++ b/sdk/formrecognizer/ai-form-recognizer/karma.conf.js @@ -47,10 +47,10 @@ module.exports = function(config) { // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor preprocessors: { "**/*.js": ["env"], - "recordings/browsers/**/*.json": ["json"] + "recordings/browsers/**/*.json": ["json"], // IMPORTANT: COMMENT following line if you want to debug in your browsers!! // Preprocess source file to calculate code coverage, however this will make source file unreadable - // "test-browser/index.js": ["coverage"] + "dist-test/index.browser.js": ["coverage"] }, envPreprocessor: [ diff --git a/sdk/formrecognizer/ai-form-recognizer/package.json b/sdk/formrecognizer/ai-form-recognizer/package.json index 1649787a702f..1ca2fef6a2e4 100644 --- a/sdk/formrecognizer/ai-form-recognizer/package.json +++ b/sdk/formrecognizer/ai-form-recognizer/package.json @@ -60,7 +60,7 @@ "extract-api": "tsc -p . && api-extractor run --local", "format": "prettier --write --config ../../.prettierrc.json \"src/**/*.ts\" \"test/**/*.ts\" \"*.{js,json}\"", "integration-test:browser": "karma start --single-run", - "integration-test:node": "mocha -r esm --require source-map-support/register --reporter ../../../common/tools/mocha-multi-reporter.js --full-trace -t 300000 dist-esm/test/*.spec.js dist-esm/test/node/*.spec.js", + "integration-test:node": "nyc mocha -r esm --require source-map-support/register --reporter ../../../common/tools/mocha-multi-reporter.js --full-trace -t 300000 dist-esm/test/*.spec.js dist-esm/test/node/*.spec.js", "integration-test": "npm run integration-test:node && npm run integration-test:browser", "lint:fix": "eslint package.json tsconfig.json api-extractor.json src test --ext .ts --fix --fix-type [problem,suggestion]", "lint": "eslint package.json tsconfig.json api-extractor.json src test --ext .ts -f html -o formrecognizer-lintReport.html || exit 0", @@ -127,6 +127,7 @@ "karma-remap-istanbul": "^0.6.0", "mocha": "^7.1.1", "mocha-junit-reporter": "^1.18.0", + "nyc": "^14.0.0", "prettier": "^1.16.4", "rimraf": "^3.0.0", "rollup": "^1.16.3",