/
testing.mjs
41 lines (35 loc) · 1.19 KB
/
testing.mjs
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
import { startVitest } from 'vitest/node'
// Set this to true when intentionally updating the snapshots
const UPDATE_SNAPSHOTS = false
const provider = process.argv[1 + process.argv.indexOf('--provider')]
const configs = [
// Run test cases. Generates coverage report.
['test/', {
include: ['test/*.test.*'],
exclude: ['coverage-report-tests/**/*'],
coverage: { enabled: true },
}],
// Run tests for checking coverage report contents.
['coverage-report-tests', {
include: [
['c8', 'istanbul'].includes(provider) && './coverage-report-tests/generic.report.test.ts',
`./coverage-report-tests/${provider}.report.test.ts`,
].filter(Boolean),
coverage: { enabled: false, clean: false },
}],
]
for (const threads of [{ threads: true }, { threads: false }, { singleThread: true }]) {
for (const isolate of [true, false]) {
for (const [directory, config] of configs) {
await startVitest('test', [directory], {
name: `With settings: ${JSON.stringify({ ...threads, isolate, directory })}`,
...config,
update: UPDATE_SNAPSHOTS,
...threads,
isolate,
})
if (process.exitCode)
process.exit()
}
}
}