-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
default.test.ts
55 lines (49 loc) · 1.88 KB
/
default.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
45
46
47
48
49
50
51
52
53
54
55
import path from 'pathe'
import { describe, expect, test } from 'vitest'
import { runVitestCli } from '../../test-utils'
const resolve = (id = '') => path.resolve(__dirname, '../fixtures/default', id)
async function run(fileFilter: string[], watch = false, ...args: string[]) {
return runVitestCli(
...fileFilter,
'--root',
resolve(),
watch ? '--watch' : '--run',
...args,
)
}
describe('default reporter', async () => {
test('normal', async () => {
const { stdout } = await run(['b1.test.ts', 'b2.test.ts'])
expect(stdout).contain('✓ b2 test')
expect(stdout).not.contain('✓ nested b1 test')
expect(stdout).contain('× b failed test')
})
test('show full test suite when only one file', async () => {
const { stdout } = await run(['a.test.ts'])
expect(stdout).contain('✓ a1 test')
expect(stdout).contain('✓ nested a3 test')
expect(stdout).contain('× a failed test')
expect(stdout).contain('nested a failed 1 test')
})
test('rerun should undo', async () => {
const vitest = await run([], true, '-t', 'passed')
// one file
vitest.write('p')
await vitest.waitForStdout('Input filename pattern')
vitest.write('a\n')
await vitest.waitForStdout('Filename pattern: a')
await vitest.waitForStdout('Waiting for file changes...')
expect(vitest.stdout).contain('✓ a1 test')
expect(vitest.stdout).contain('✓ nested a3 test')
// rerun and two files
vitest.write('p')
await vitest.waitForStdout('Input filename pattern')
vitest.write('b\n')
await vitest.waitForStdout('Waiting for file changes...')
expect(vitest.stdout).toContain('✓ b1.test.ts')
expect(vitest.stdout).toContain('✓ b2.test.ts')
expect(vitest.stdout).not.toContain('✓ nested b1 test')
expect(vitest.stdout).not.toContain('✓ b1 test')
expect(vitest.stdout).not.toContain('✓ b2 test')
})
}, 120000)