/
default.test.ts
60 lines (53 loc) · 1.86 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
56
57
58
59
60
import { describe, expect, test } from 'vitest'
import { runVitest, runVitestCli } from '../../test-utils'
describe('default reporter', async () => {
test('normal', async () => {
const { stdout } = await runVitest({
include: ['b1.test.ts', 'b2.test.ts'],
root: 'fixtures/default',
reporters: 'none',
})
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 runVitest({
include: ['a.test.ts'],
root: 'fixtures/default',
reporters: 'none',
})
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 runVitestCli(
'--root',
'fixtures/default',
'--watch',
'-t',
'passed',
)
vitest.resetOutput()
// 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)