/
runner.test.ts
51 lines (46 loc) · 1.28 KB
/
runner.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
import { resolve } from 'pathe'
import fg from 'fast-glob'
import { execa } from 'execa'
import { describe, expect, it } from 'vitest'
describe('should fail', async () => {
const root = resolve(__dirname, '../failing')
const files = await fg('*.test-d.*', { cwd: root })
it('typecheck files', async () => {
const { stderr } = await execa('npx', [
'vitest',
'typecheck',
'--run',
'--dir',
resolve(__dirname, '..', './failing'),
'--config',
resolve(__dirname, './vitest.config.ts'),
], {
cwd: root,
reject: false,
env: {
...process.env,
CI: 'true',
NO_COLOR: 'true',
},
})
expect(stderr).toBeTruthy()
const lines = String(stderr).split(/\n/g)
const msg = lines
.filter(i => i.includes('TypeCheckError: '))
.reverse()
.join('\n')
.trim()
.replace(root, '<rootDir>')
expect(stderr).not.toMatch('files found, exiting with code')
expect(msg).toMatchSnapshot()
files.forEach((file) => {
expect(String(stderr)).toMatch(`${file}:`)
})
lines.forEach((line, idx) => {
if (line.includes('TypeCheckError')) {
const msg = lines.slice(idx - 1, idx + 7).join('\n')
expect(msg).toMatchSnapshot()
}
})
}, 30_000)
})