Skip to content

Commit 3c2be35

Browse files
committed
XUnit results experiment
1 parent a08940b commit 3c2be35

File tree

4 files changed

+36
-1
lines changed

4 files changed

+36
-1
lines changed

.evergreen.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ post:
6060
visibility: signed
6161
content_type: application/x-gzip
6262
optional: true
63+
- command: attach.xunit_results
64+
params:
65+
file: src/.logs/*.xml
6366

6467

6568
# Functions are any command that can be run.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,4 @@ mongocryptd.pid
2626
.sbom
2727
.nvm
2828
snapshot.blob
29+
.logs

packages/e2e-tests/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"url": "git://github.com/mongodb-js/mongosh.git"
1212
},
1313
"scripts": {
14-
"test": "mocha -r ts-node/register -r \"../../scripts/import-expansions.js\" -r \"./test/test-shell-context.ts\" --timeout 15000 --colors \"./test/*.spec.ts\"",
14+
"test": "mocha -r ts-node/register -r \"../../scripts/import-expansions.js\" -r \"./test/test-shell-context.ts\" --reporter \"./reporter.ts\" --timeout 15000 --colors \"./test/*.spec.ts\"",
1515
"test-ci": "node ../../scripts/run-if-package-requested.js npm test",
1616
"test-coverage": "nyc --no-clean --cwd ../.. --reporter=none npm run test",
1717
"test-ci-coverage": "nyc --no-clean --cwd ../.. --reporter=none npm run test-ci",

packages/e2e-tests/reporter.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { reporters } from 'mocha';
2+
import type { MochaOptions, Runner } from 'mocha';
3+
import path from 'path';
4+
5+
// Import the built-in reporters
6+
const Spec = reporters.Spec;
7+
const XUnit = reporters.XUnit;
8+
9+
export class MochaReporter extends reporters.Base {
10+
constructor(runner: Runner, options: MochaOptions) {
11+
super(runner, options);
12+
const suiteName = path.basename(process.cwd());
13+
14+
new Spec(runner);
15+
16+
runner.on('suite', (suite) => {
17+
if (suite.parent?.root) {
18+
suite.title = `${suiteName}__${suite.title}`;
19+
}
20+
});
21+
22+
new XUnit(runner, {
23+
reporterOptions: {
24+
suiteName,
25+
output: path.join(__dirname, '..', '..', '.logs', `${suiteName}.xml`),
26+
},
27+
});
28+
}
29+
}
30+
31+
module.exports = MochaReporter;

0 commit comments

Comments
 (0)