-
-
Notifications
You must be signed in to change notification settings - Fork 46
Expand file tree
/
Copy pathtest-reporter.mts
More file actions
30 lines (25 loc) · 824 Bytes
/
test-reporter.mts
File metadata and controls
30 lines (25 loc) · 824 Bytes
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
/* node:coverage disable */
import { spec, type TestEvent } from "node:test/reporters"
import { Transform, type TransformCallback } from "node:stream"
class Reporter extends Transform {
readonly specReporter: Transform
constructor() {
super({ __proto__: null, writableObjectMode: true } as any) // https://github.com/microsoft/TypeScript/issues/38385
this.specReporter = new spec()
}
_transform(event: TestEvent, encoding: BufferEncoding, callback: TransformCallback) {
switch (event.type) {
case "test:stdout":
case "test:stderr":
callback(null)
break
default:
this.specReporter._transform(event, encoding, callback)
break
}
}
_flush(callback: TransformCallback) {
this.specReporter._flush(callback)
}
}
export default new Reporter()