/
testname-pattern.test.ts
32 lines (24 loc) · 1.16 KB
/
testname-pattern.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
import { resolve } from 'pathe'
import { expect, test } from 'vitest'
import { runVitest } from '../../test-utils'
test('match by partial pattern', async () => {
const { stdout } = await runVitest({ root: './fixtures' }, ['example'])
expect(stdout).toMatch('✓ test/example.test.ts > this will pass')
expect(stdout).toMatch('Test Files 1 passed (1)')
expect(stdout).not.toMatch('test/filters.test.ts')
})
test('match by full test file name', async () => {
const filename = resolve('./fixtures/test/example.test.ts')
const { stdout } = await runVitest({ root: './fixtures' }, [filename])
expect(stdout).toMatch('✓ test/example.test.ts > this will pass')
expect(stdout).toMatch('Test Files 1 passed (1)')
expect(stdout).not.toMatch('test/filters.test.ts')
})
test('match by pattern that also matches current working directory', async () => {
const filter = 'filters'
expect(process.cwd()).toMatch(filter)
const { stdout } = await runVitest({ root: './fixtures' }, [filter])
expect(stdout).toMatch('✓ test/filters.test.ts > this will pass')
expect(stdout).toMatch('Test Files 1 passed (1)')
expect(stdout).not.toMatch('test/example.test.ts')
})