Skip to content

Commit 82215a9

Browse files
authored
Replace mocha-junit-reporter with Mocha builtin xunit reporter (Azure#27992)
mocha-junit-reporter doesn't support --parallel: michaelleeallen/mocha-junit-reporter#127 Also update core packages to remove dependency on mocha-junit-reporter
1 parent 4d8911e commit 82215a9

File tree

18 files changed

+13
-28
lines changed

18 files changed

+13
-28
lines changed

common/tools/dev-tool/src/commands/run/testNodeJSInput.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,13 @@ export const commandInfo = makeCommandInfo(
2121
);
2222

2323
export default leafCommand(commandInfo, async (options) => {
24+
const reporterArgs =
25+
"--reporter ../../../common/tools/mocha-multi-reporter.js --reporter-option output=test-results.xml";
2426
const defaultMochaArgs = `${
2527
(await isModuleProject())
2628
? "-r source-map-support/register.js"
2729
: "-r ../../../common/tools/esm-workaround -r esm -r source-map-support/register"
28-
} --reporter ../../../common/tools/mocha-multi-reporter.js --full-trace`;
30+
} ${reporterArgs} --full-trace`;
2931
const updatedArgs = options["--"]?.map((opt) =>
3032
opt.includes("**") && !opt.startsWith("'") && !opt.startsWith('"') ? `"${opt}"` : opt,
3133
);

common/tools/dev-tool/src/commands/run/testNodeTSInput.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,11 @@ export const commandInfo = makeCommandInfo(
2222

2323
export default leafCommand(commandInfo, async (options) => {
2424
const isModuleProj = await isModuleProject();
25+
const reporterArgs =
26+
"--reporter ../../../common/tools/mocha-multi-reporter.js --reporter-option output=test-results.xml";
2527
const defaultMochaArgs = `${
2628
isModuleProj ? "" : "-r esm "
27-
}-r ts-node/register --reporter ../../../common/tools/mocha-multi-reporter.js --full-trace`;
29+
}-r ts-node/register ${reporterArgs} --full-trace`;
2830
const updatedArgs = options["--"]?.map((opt) =>
2931
opt.includes("**") && !opt.startsWith("'") && !opt.startsWith('"') ? `"${opt}"` : opt,
3032
);

common/tools/mocha-multi-reporter.js

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,22 @@
33
"use strict";
44

55
const Mocha = require("mocha");
6-
const MochaJUnitReporter = require("mocha-junit-reporter");
76

87
/**
98
* Usage :
10-
* - Meant to be used to leverage Mocha's Spec reporter as well as mocha-junit-reporter for the test runs
11-
* - Provide the relative path to this file from your `sdk/service/package-folder/` as the reporter options to mocha
12-
* - Example - `--reporter ../../../common/tools/mocha-multi-reporter.js`
9+
* - Meant to be used to leverage Mocha's buitin Spec and XUnit reporters
10+
* - Provide the relative path to this file from your `sdk/service/package-folder/` to mocha
11+
* - Example - `--reporter ../../../common/tools/mocha-multi-reporter.js --report-option ...`
1312
*
1413
* Refer the following docs for more customizations on reporters
1514
* https://mochajs.org/api/tutorial-custom-reporter.html
1615
*
1716
* @class MultiReporter
1817
*/
1918
class MultiReporter {
20-
constructor(runner) {
21-
// Spec reporter is provided as part of mocha library
22-
// Invoking the spec reporter with the runner
23-
new Mocha.reporters.Spec(runner);
24-
// Invoking mocha-junit-reporter to generate XML reports of test summaries for CI
25-
new MochaJUnitReporter(runner);
19+
constructor(runner, options) {
20+
new Mocha.reporters.Spec(runner, options);
21+
new Mocha.reporters.XUnit(runner, options);
2622
}
2723
}
2824

sdk/core/abort-controller/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@
9292
"karma-mocha-reporter": "^2.2.5",
9393
"karma-sourcemap-loader": "^0.3.8",
9494
"mocha": "^10.0.0",
95-
"mocha-junit-reporter": "^2.0.0",
9695
"c8": "^8.0.0",
9796
"prettier": "^2.5.1",
9897
"rimraf": "^3.0.0",

sdk/core/core-amqp/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
"test:node": "npm run clean && tsc -p . && npm run unit-test:node && npm run integration-test:node",
6161
"test": "npm run clean && tsc -p . && npm run unit-test:node && npm run bundle && npm run unit-test:browser && npm run integration-test",
6262
"unit-test:browser": "karma start --single-run",
63-
"unit-test:node": "cross-env TS_NODE_FILES=true TS_NODE_COMPILER_OPTIONS=\"{\\\"module\\\":\\\"commonjs\\\"}\" mocha -r ts-node/register --reporter ../../../common/tools/mocha-multi-reporter.js --timeout 50000 --full-trace --exclude \"test/**/browser/*.spec.ts\" \"test/**/*.spec.ts\"",
63+
"unit-test:node": "cross-env TS_NODE_FILES=true dev-tool run test:node-ts-input --no-test-proxy=true",
6464
"unit-test": "npm run unit-test:node && npm run unit-test:browser"
6565
},
6666
"engines": {
@@ -104,7 +104,6 @@
104104
"karma-chrome-launcher": "^3.0.0",
105105
"karma-mocha": "^2.0.1",
106106
"mocha": "^10.0.0",
107-
"mocha-junit-reporter": "^2.0.0",
108107
"c8": "^8.0.0",
109108
"prettier": "^2.5.1",
110109
"puppeteer": "^19.2.2",

sdk/core/core-auth/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@
7979
"eslint": "^8.0.0",
8080
"inherits": "^2.0.3",
8181
"mocha": "^10.0.0",
82-
"mocha-junit-reporter": "^2.0.0",
8382
"prettier": "^2.5.1",
8483
"rimraf": "^3.0.0",
8584
"typescript": "~5.2.0",

sdk/core/core-client-rest/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@
8484
"karma-mocha": "^2.0.1",
8585
"karma-sourcemap-loader": "^0.3.8",
8686
"karma": "^6.2.0",
87-
"mocha-junit-reporter": "^2.0.0",
8887
"mocha": "^10.0.0",
8988
"prettier": "^2.5.1",
9089
"rimraf": "^3.0.0",

sdk/core/core-client/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@
100100
"karma-mocha-reporter": "^2.2.5",
101101
"karma-sourcemap-loader": "^0.3.8",
102102
"mocha": "^10.0.0",
103-
"mocha-junit-reporter": "^2.0.0",
104103
"prettier": "^2.5.1",
105104
"rimraf": "^3.0.0",
106105
"sinon": "^17.0.0",

sdk/core/core-http-compat/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@
6363
"@azure/test-utils": "^1.0.0",
6464
"@azure/dev-tool": "^1.0.0",
6565
"@microsoft/api-extractor": "^7.31.1",
66-
"mocha-junit-reporter": "^2.0.0",
6766
"mocha": "^10.0.0",
6867
"eslint": "^8.0.0",
6968
"rimraf": "^3.0.0",

sdk/core/core-lro/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@
116116
"karma-mocha-reporter": "^2.2.5",
117117
"karma-sourcemap-loader": "^0.3.8",
118118
"mocha": "^10.0.0",
119-
"mocha-junit-reporter": "^2.0.0",
120119
"c8": "^8.0.0",
121120
"prettier": "^2.5.1",
122121
"rimraf": "^3.0.0",

0 commit comments

Comments
 (0)