/
bail.test.ts
36 lines (28 loc) · 1.34 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
import { type UserConfig, expect, test } from 'vitest'
import { runVitest } from '../../test-utils'
const configs: UserConfig[] = []
const pools: UserConfig[] = [{ threads: true }, { threads: false }, { singleThread: true }]
if (process.platform !== 'win32')
pools.push({ browser: { enabled: true, name: 'chrome' } })
for (const isolate of [true, false]) {
for (const pool of pools)
configs.push({ isolate, ...pool })
}
for (const config of configs) {
test(`should bail with "${JSON.stringify(config)}"`, async () => {
process.env.THREADS = config?.threads ? 'true' : 'false'
const { exitCode, stdout } = await runVitest({
root: './fixtures',
bail: 1,
...config,
})
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')
})
}