-
Notifications
You must be signed in to change notification settings - Fork 299
/
Copy pathreporter.ts
40 lines (34 loc) · 1.2 KB
/
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
36
37
38
39
40
// Custom Jest reporter used by jest-vscode extension
import {
Reporter,
TestContext,
ReporterOnStartOptions,
Test,
TestResult,
AggregatedResult,
} from '@jest/reporters';
import type { TestResultJestRunEventArguments } from './JestExt';
class VSCodeJestReporter implements Reporter {
onRunStart(aggregatedResults: AggregatedResult, _options: ReporterOnStartOptions): void {
process.stderr.write(
`onRunStart: numTotalTestSuites: ${aggregatedResults.numTotalTestSuites}\r\n`
);
}
onRunComplete(_contexts: Set<TestContext>, results: AggregatedResult): void {
// report exec errors that could have prevented Result file being generated
if (results.runExecError) {
process.stderr.write(`onRunComplete: execError: ${results.runExecError.message}\r\n`);
} else {
process.stderr.write('onRunComplete\r\n');
}
}
getLastError(): Error | undefined {
return;
}
onTestResult(_test: Test, _testResult: TestResult, aggregatedResult: AggregatedResult): void {
process.stderr.write(
`onTestResult: test: ${JSON.stringify({ aggregatedResult: aggregatedResult } as TestResultJestRunEventArguments)}\r\n`
);
}
}
module.exports = VSCodeJestReporter;