-
Notifications
You must be signed in to change notification settings - Fork 1
/
.vscode-ci-test-reporter.js
53 lines (50 loc) · 1.68 KB
/
.vscode-ci-test-reporter.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
const BaseReporter = require('mocha/lib/reporters/base');
const SpecReporter = require('mocha/lib/reporters/spec');
const JsonReporter = require('mocha/lib/reporters/json');
const Mocha = require('mocha');
module.exports = class MultiReporter extends BaseReporter {
reporters;
constructor(runner, options) {
super(runner, options);
this.reporters = [
new SpecReporter(runner, {
reporterOption: options.reporterOption.specReporterOption,
}),
new JsonReporter(runner, {
reporterOption: options.reporterOption.jsonReporterOption,
}),
new (class TestExecutionLogReporter {
constructor(runner) {
let indent = 0;
function log(txt) {
console.log(' '.repeat(indent * 2) + txt)
}
runner.on(Mocha.Runner.constants.EVENT_RUN_BEGIN, () => {
log('Begin Run')
indent++;
});
runner.on(Mocha.Runner.constants.EVENT_RUN_END, () => {
indent--;
log('End Run')
});
runner.on(Mocha.Runner.constants.EVENT_SUITE_BEGIN, (suite) => {
log(`Begin Suite '${suite.titlePath()}'`)
indent++;
});
runner.on(Mocha.Runner.constants.EVENT_SUITE_END, (suite) => {
indent--;
log(`End Suite '${suite.titlePath()}'`)
});
runner.on(Mocha.Runner.constants.EVENT_TEST_BEGIN, (test) => {
log(`Begin Test '${test.title}'`)
indent++;
});
runner.on(Mocha.Runner.constants.EVENT_TEST_END, (test) => {
indent--;
log(`End Test '${test.title}'`)
});
}
})(runner),
];
}
};