Skip to content

Commit

Permalink
Update karma test configuration for track2 packages (#13309)
Browse files Browse the repository at this point in the history
This PR removes our dependency on the unmaintained package "karma-remap-istanbul" and replaces it with a smaller karma plugin ("karma-sourcemap-loader") that allows karma-coverage to load source maps from the disk correctly.

I tested and confirmed that the generated coverage data has the correct source TS files.
  • Loading branch information
xirzec authored Jan 22, 2021
1 parent e75a0b7 commit 40b027d
Show file tree
Hide file tree
Showing 78 changed files with 694 additions and 841 deletions.
574 changes: 313 additions & 261 deletions common/config/rush/pnpm-lock.yaml

Large diffs are not rendered by default.

23 changes: 20 additions & 3 deletions dataplane.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
"name": "communication-chat",
"path": "sdk/communication/communication-chat"
},
{
"name": "communication-common",
"path": "sdk/communication/communication-common"
},
{
"name": "communication-sms",
"path": "sdk/communication/communication-sms"
Expand Down Expand Up @@ -70,7 +74,7 @@
},
{
"name": "eventgrid",
"path": "sdk\\eventgrid\\eventgrid"
"path": "sdk/eventgrid/eventgrid"
},
{
"name": "event-hubs",
Expand All @@ -96,6 +100,10 @@
"name": "identity",
"path": "sdk/identity/identity"
},
{
"name": "keyvault-admin",
"path": "sdk/keyvault/keyvault-admin"
},
{
"name": "keyvault-certificates",
"path": "sdk/keyvault/keyvault-certificates"
Expand All @@ -114,12 +122,16 @@
},
{
"name": "metrics-advisor",
"path": "sdk\\metricsadvisor\\ai-metrics-advisor"
"path": "sdk/metricsadvisor/ai-metrics-advisor"
},
{
"name": "schema-registry",
"path": "sdk/schemaregistry/schema-registry"
},
{
"name": "schema-registry-avro",
"path": "sdk/schemaregistry/schema-registry-avro"
},
{
"name": "search",
"path": "sdk/search/search-documents"
Expand Down Expand Up @@ -209,7 +221,12 @@
"path": "sdk/test-utils/multi-version"
},
{
"path": "sdk\\digitaltwins\\digital-twins-core"
"name": "digital-twins-core",
"path": "sdk/digitaltwins/digital-twins-core"
},
{
"name": "attestation",
"path": "sdk/attestation/attestation"
}
],
"settings": {
Expand Down
23 changes: 9 additions & 14 deletions sdk/anomalydetector/ai-anomaly-detector/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ module.exports = function(config) {
"karma-ie-launcher",
"karma-env-preprocessor",
"karma-coverage",
"karma-remap-istanbul",
"karma-sourcemap-loader",
"karma-junit-reporter",
"karma-json-preprocessor",
"karma-json-to-file-reporter"
Expand All @@ -44,7 +44,7 @@ module.exports = function(config) {
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
"**/*.js": ["env"],
"**/*.js": ["sourcemap", "env"],
"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
Expand All @@ -56,22 +56,17 @@ module.exports = function(config) {
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ["mocha", "coverage", "karma-remap-istanbul", "junit", "json-to-file"],
reporters: ["mocha", "coverage", "junit", "json-to-file"],

coverageReporter: {
// specify a common output directory
dir: "coverage-browser/",
reporters: [{ type: "json", subdir: ".", file: "coverage.json" }]
},

remapIstanbulReporter: {
src: "coverage-browser/coverage.json",
reports: {
lcovonly: "coverage-browser/lcov.info",
html: "coverage-browser/html/report",
"text-summary": null,
cobertura: "./coverage-browser/cobertura-coverage.xml"
}
reporters: [
{ type: "json", subdir: ".", file: "coverage.json" },
{ type: "lcovonly", subdir: ".", file: "lcov.info" },
{ type: "html", subdir: "html" },
{ type: "cobertura", subdir: ".", file: "cobertura-coverage.xml" }
]
},

junitReporter: {
Expand Down
2 changes: 1 addition & 1 deletion sdk/anomalydetector/ai-anomaly-detector/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
"karma-junit-reporter": "^2.0.1",
"karma-mocha": "^2.0.1",
"karma-mocha-reporter": "^2.2.5",
"karma-remap-istanbul": "^0.6.0",
"karma-sourcemap-loader": "^0.3.8",
"mocha": "^7.1.1",
"mocha-junit-reporter": "^1.18.0",
"nyc": "^14.0.0",
Expand Down
21 changes: 8 additions & 13 deletions sdk/appconfiguration/app-configuration/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module.exports = function(config) {
"karma-ie-launcher",
"karma-env-preprocessor",
"karma-coverage",
"karma-remap-istanbul",
"karma-sourcemap-loader",
"karma-junit-reporter"
],

Expand Down Expand Up @@ -59,22 +59,17 @@ module.exports = function(config) {
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ["mocha", "coverage", "karma-remap-istanbul", "junit"],
reporters: ["mocha", "coverage", "junit"],

coverageReporter: {
// specify a common output directory
dir: "coverage-browser/",
reporters: [{ type: "json", subdir: ".", file: "coverage.json" }]
},

remapIstanbulReporter: {
src: "coverage-browser/coverage.json",
reports: {
lcovonly: "coverage-browser/lcov.info",
html: "coverage-browser/html/report",
"text-summary": null,
cobertura: "./coverage-browser/cobertura-coverage.xml"
}
reporters: [
{ type: "json", subdir: ".", file: "coverage.json" },
{ type: "lcovonly", subdir: ".", file: "lcov.info" },
{ type: "html", subdir: "html" },
{ type: "cobertura", subdir: ".", file: "cobertura-coverage.xml" }
]
},

junitReporter: {
Expand Down
2 changes: 1 addition & 1 deletion sdk/appconfiguration/app-configuration/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
"karma-junit-reporter": "^2.0.1",
"karma-mocha": "^2.0.1",
"karma-mocha-reporter": "^2.2.5",
"karma-remap-istanbul": "^0.6.0",
"karma-sourcemap-loader": "^0.3.8",
"mocha": "^7.1.1",
"mocha-junit-reporter": "^1.18.0",
"nock": "^12.0.3",
Expand Down
21 changes: 8 additions & 13 deletions sdk/attestation/attestation/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ module.exports = function(config) {
"karma-ie-launcher",
"karma-env-preprocessor",
"karma-coverage",
"karma-remap-istanbul",
"karma-sourcemap-loader",
"karma-junit-reporter",
"karma-json-to-file-reporter",
"karma-source-map-support",
Expand Down Expand Up @@ -71,22 +71,17 @@ module.exports = function(config) {
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ["mocha", "coverage", "karma-remap-istanbul", "junit", "json-to-file"],
reporters: ["mocha", "coverage", "junit", "json-to-file"],

coverageReporter: {
// specify a common output directory
dir: "coverage-browser/",
reporters: [{ type: "json", subdir: ".", file: "coverage.json" }]
},

remapIstanbulReporter: {
src: "coverage-browser/coverage.json",
reports: {
lcovonly: "coverage-browser/lcov.info",
html: "coverage-browser/html/report",
"text-summary": null,
cobertura: "./coverage-browser/cobertura-coverage.xml"
}
reporters: [
{ type: "json", subdir: ".", file: "coverage.json" },
{ type: "lcovonly", subdir: ".", file: "lcov.info" },
{ type: "html", subdir: "html" },
{ type: "cobertura", subdir: ".", file: "cobertura-coverage.xml" }
]
},

junitReporter: {
Expand Down
2 changes: 1 addition & 1 deletion sdk/attestation/attestation/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"karma-junit-reporter": "^2.0.1",
"karma-mocha": "^2.0.1",
"karma-mocha-reporter": "^2.2.5",
"karma-remap-istanbul": "^0.6.0",
"karma-sourcemap-loader": "^0.3.8",
"karma-source-map-support": "~1.4.0",
"mocha": "^7.1.1",
"nyc": "^14.0.0",
Expand Down
25 changes: 7 additions & 18 deletions sdk/communication/communication-administration/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ module.exports = function(config) {
"karma-ie-launcher",
"karma-env-preprocessor",
"karma-coverage",
"karma-remap-istanbul",
"karma-sourcemap-loader",
"karma-junit-reporter",
"karma-json-to-file-reporter",
"karma-json-preprocessor"
Expand All @@ -46,7 +46,7 @@ module.exports = function(config) {
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
"**/*.js": ["env"],
"**/*.js": ["sourcemap", "env"],
"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
Expand All @@ -69,30 +69,19 @@ module.exports = function(config) {
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ["mocha", "coverage", "karma-remap-istanbul", "junit", "json-to-file"],
reporters: ["mocha", "coverage", "junit", "json-to-file"],

coverageReporter: {
// specify a common output directory
dir: "coverage-browser/",
reporters: [
{
type: "json",
subdir: ".",
file: "coverage.json"
}
{ type: "json", subdir: ".", file: "coverage.json" },
{ type: "lcovonly", subdir: ".", file: "lcov.info" },
{ type: "html", subdir: "html" },
{ type: "cobertura", subdir: ".", file: "cobertura-coverage.xml" }
]
},

remapIstanbulReporter: {
src: "coverage-browser/coverage.json",
reports: {
lcovonly: "coverage-browser/lcov.info",
html: "coverage-browser/html/report",
"text-summary": null,
cobertura: "./coverage-browser/cobertura-coverage.xml"
}
},

junitReporter: {
outputDir: "", // results will be saved as $outputDir/$browserName.xml
outputFile: "test-results.browser.xml", // if included, results will be saved as $outputDir/$browserName/$outputFile
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
"karma-junit-reporter": "^2.0.1",
"karma-mocha-reporter": "^2.2.5",
"karma-mocha": "^2.0.1",
"karma-remap-istanbul": "^0.6.0",
"karma-sourcemap-loader": "^0.3.8",
"karma": "^5.1.0",
"mocha-junit-reporter": "^1.18.0",
"mocha": "^7.1.1",
Expand Down
25 changes: 7 additions & 18 deletions sdk/communication/communication-chat/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ module.exports = function(config) {
"karma-ie-launcher",
"karma-env-preprocessor",
"karma-coverage",
"karma-remap-istanbul",
"karma-sourcemap-loader",
"karma-junit-reporter",
"karma-json-to-file-reporter",
"karma-json-preprocessor"
Expand All @@ -46,7 +46,7 @@ module.exports = function(config) {
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
"**/*.js": ["env"],
"**/*.js": ["sourcemap", "env"],
"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
Expand All @@ -61,30 +61,19 @@ module.exports = function(config) {
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ["mocha", "coverage", "karma-remap-istanbul", "junit", "json-to-file"],
reporters: ["mocha", "coverage", "junit", "json-to-file"],

coverageReporter: {
// specify a common output directory
dir: "coverage-browser/",
reporters: [
{
type: "json",
subdir: ".",
file: "coverage.json"
}
{ type: "json", subdir: ".", file: "coverage.json" },
{ type: "lcovonly", subdir: ".", file: "lcov.info" },
{ type: "html", subdir: "html" },
{ type: "cobertura", subdir: ".", file: "cobertura-coverage.xml" }
]
},

remapIstanbulReporter: {
src: "coverage-browser/coverage.json",
reports: {
lcovonly: "coverage-browser/lcov.info",
html: "coverage-browser/html/report",
"text-summary": null,
cobertura: "./coverage-browser/cobertura-coverage.xml"
}
},

junitReporter: {
outputDir: "", // results will be saved as $outputDir/$browserName.xml
outputFile: "test-results.browser.xml", // if included, results will be saved as $outputDir/$browserName/$outputFile
Expand Down
2 changes: 1 addition & 1 deletion sdk/communication/communication-chat/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
"karma-junit-reporter": "^2.0.1",
"karma-mocha-reporter": "^2.2.5",
"karma-mocha": "^2.0.1",
"karma-remap-istanbul": "^0.6.0",
"karma-sourcemap-loader": "^0.3.8",
"karma": "^5.1.0",
"mocha-junit-reporter": "^1.18.0",
"mocha": "^7.1.1",
Expand Down
23 changes: 6 additions & 17 deletions sdk/communication/communication-common/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module.exports = function(config) {
"karma-ie-launcher",
"karma-env-preprocessor",
"karma-coverage",
"karma-remap-istanbul",
"karma-sourcemap-loader",
"karma-junit-reporter"
],

Expand Down Expand Up @@ -51,30 +51,19 @@ module.exports = function(config) {
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ["mocha", "coverage", "karma-remap-istanbul", "junit"],
reporters: ["mocha", "coverage", "junit"],

coverageReporter: {
// specify a common output directory
dir: "coverage-browser/",
reporters: [
{
type: "json",
subdir: ".",
file: "coverage.json"
}
{ type: "json", subdir: ".", file: "coverage.json" },
{ type: "lcovonly", subdir: ".", file: "lcov.info" },
{ type: "html", subdir: "html" },
{ type: "cobertura", subdir: ".", file: "cobertura-coverage.xml" }
]
},

remapIstanbulReporter: {
src: "coverage-browser/coverage.json",
reports: {
lcovonly: "coverage-browser/lcov.info",
html: "coverage-browser/html/report",
"text-summary": null,
cobertura: "./coverage-browser/cobertura-coverage.xml"
}
},

junitReporter: {
outputDir: "", // results will be saved as $outputDir/$browserName.xml
outputFile: "test-results.browser.xml", // if included, results will be saved as $outputDir/$browserName/$outputFile
Expand Down
2 changes: 1 addition & 1 deletion sdk/communication/communication-common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
"karma-junit-reporter": "^2.0.1",
"karma-mocha-reporter": "^2.2.5",
"karma-mocha": "^2.0.1",
"karma-remap-istanbul": "^0.6.0",
"karma-sourcemap-loader": "^0.3.8",
"karma": "^5.1.0",
"mocha-junit-reporter": "^1.18.0",
"mocha": "^7.1.1",
Expand Down
Loading

0 comments on commit 40b027d

Please sign in to comment.