/
bail.test.ts
44 lines (38 loc) · 1.4 KB
/
bail.test.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
import { expect, test } from 'vitest'
import { execa } from 'execa'
const configs: string[][] = []
const pools = [['--threads', 'true'], ['--threads', 'false'], ['--single-thread']]
if (process.platform !== 'win32')
pools.push(['--browser'])
for (const isolate of ['true', 'false']) {
for (const pool of pools) {
configs.push([
'--bail',
'1',
'--isolate',
isolate,
...pool,
])
}
}
for (const config of configs) {
test(`should bail with "${config.join(' ')}"`, async () => {
const { exitCode, stdout } = await execa('vitest', [
'--no-color',
'--root',
'fixtures',
...config,
], {
reject: false,
env: { THREADS: config.join(' ').includes('--threads true') ? 'true' : 'false' },
})
expect(exitCode).toBe(1)
expect(stdout).toMatch('✓ test/first.test.ts > 1 - first.test.ts - this should pass')
expect(stdout).toMatch('× test/first.test.ts > 2 - first.test.ts - this should fail')
// Cancelled tests should not be run
expect(stdout).not.toMatch('test/first.test.ts > 3 - first.test.ts - this should be skipped')
expect(stdout).not.toMatch('test/second.test.ts > 1 - second.test.ts - this should be skipped')
expect(stdout).not.toMatch('test/second.test.ts > 2 - second.test.ts - this should be skipped')
expect(stdout).not.toMatch('test/second.test.ts > 3 - second.test.ts - this should be skipped')
})
}