forked from Dart-Code/Dart-Code
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmocha_logging_reporter.ts
35 lines (28 loc) · 1.09 KB
/
mocha_logging_reporter.ts
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
import { ITest, reporters } from "mocha";
import { LogCategory, LogSeverity } from "../src/debug/utils";
import { log } from "../src/utils/log";
import testRunner = require("vscode/lib/testrunner");
export class LoggingReporter extends reporters.Base {
constructor(runner: any, options: any) {
super(runner);
// runner.on("start", () => { });
runner.on("test", (test: ITest) => {
log(`Starting test ${test.fullTitle()}...`, LogSeverity.Info, LogCategory.CI);
});
runner.on("pending", (test: ITest) => {
log(`Test ${test.fullTitle()} pending/skipped`, LogSeverity.Info, LogCategory.CI);
});
runner.on("pass", (test: ITest) => {
log(`Test ${test.fullTitle()} passed after ${test.duration}ms`, LogSeverity.Info, LogCategory.CI);
});
runner.on("fail", (test: ITest) => {
log(`Test ${test.fullTitle()} failed after ${test.duration}ms`, LogSeverity.Error, LogCategory.CI);
const err = (test as any).err;
if (err) {
log(err.message, LogSeverity.Error, LogCategory.CI);
log(err.stack, LogSeverity.Error, LogCategory.CI);
}
});
// runner.once("end", () => { });
}
}