This repository has been archived by the owner on Feb 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathreporter.ts
82 lines (69 loc) · 1.77 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import type {
AggregatedResult,
Config,
Context,
Reporter,
ReporterOnStartOptions,
Test,
TestResult,
} from '@jest/reporters'
export default class JestReporter implements Reporter {
private _error?: Error
protected _globalConfig: Config.GlobalConfig
protected _options?: any
constructor(globalConfig: Config.GlobalConfig, options?: any) {
this._globalConfig = globalConfig
this._options = options
}
log(message: string): void {
console.log(`log message: ${JSON.stringify(message, null, 2)}`)
}
onRunStart(
aggregatedResults: AggregatedResult,
options: ReporterOnStartOptions
): void {
console.log(
`onRunStart aggregatedResults: ${JSON.stringify(
aggregatedResults,
null,
2
)}`
)
console.log(`onRunStart options: ${JSON.stringify(options, null, 2)}`)
}
onTestStart(test?: Test): void {
console.log(`onTestStart test: ${JSON.stringify(test, null, 2)}`)
}
onTestResult(
test: Test,
testResult: TestResult,
aggregatedResults: AggregatedResult
): void {
console.log(`onTestResult test: ${JSON.stringify(test, null, 2)}`)
console.log(
`onTestResult testResult: ${JSON.stringify(testResult, null, 2)}`
)
console.log(
`onTestResult aggregatedResults: ${JSON.stringify(
aggregatedResults,
null,
2
)}`
)
}
onRunComplete(
test?: Set<Context>,
runResults?: AggregatedResult
): Promise<void> | void {
console.log(`onRunComplete test: ${JSON.stringify(test, null, 2)}`)
console.log(
`onRunComplete runResults: ${JSON.stringify(runResults, null, 2)}`
)
}
getLastError(): Error | undefined {
return this._error
}
protected _setError(error: Error): void {
this._error = error
}
}