-
-
Notifications
You must be signed in to change notification settings - Fork 751
Expand file tree
/
Copy pathcapture_test_before.js
More file actions
31 lines (26 loc) · 822 Bytes
/
Copy pathcapture_test_before.js
File metadata and controls
31 lines (26 loc) · 822 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
31
import fs from 'fs'
import event from '../../../../lib/event.js'
export default function (config) {
const captured = []
event.dispatcher.on(event.test.before, test => {
captured.push({
phase: 'test.before',
title: test?.title ?? null,
tags: Array.isArray(test?.tags) ? [...test.tags] : null,
})
})
event.dispatcher.on(event.test.after, test => {
captured.push({
phase: 'test.after',
title: test?.title ?? null,
tags: Array.isArray(test?.tags) ? [...test.tags] : null,
})
})
const flush = () => {
const outPath = config.outputFile || process.env.CAPTURE_OUTPUT
if (!outPath) return
fs.writeFileSync(outPath, JSON.stringify(captured, null, 2))
}
event.dispatcher.on(event.all.result, flush)
event.dispatcher.on(event.all.after, flush)
}