forked from fi3ework/vite-plugin-checker
/
test.spec.ts
41 lines (37 loc) 路 1.31 KB
/
test.spec.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
import stringify from 'fast-json-stable-stringify'
import { describe, expect, it } from 'vitest'
import {
diagnostics,
editFile,
expectStderrContains,
isBuild,
isServe,
log,
resetReceivedLog,
sleepForEdit,
sleepForServerReady,
stripedLog,
} from '../../testUtils'
describe('vue-tsc-vue3', () => {
describe.runIf(isServe)('serve', () => {
it('get initial error and subsequent error', async () => {
await sleepForServerReady(2)
expect(stringify(diagnostics)).toMatchSnapshot()
expect(stripedLog).toMatchSnapshot()
console.log('-- edit file --')
resetReceivedLog()
editFile('src/App.vue', (code) =>
code.replace('<HelloWorld msg1="Diana" />', '<HelloWorld msg2="Diana" />')
)
await sleepForEdit(2)
expect(stringify(diagnostics)).toMatchSnapshot()
expect(stripedLog).toMatchSnapshot()
})
})
describe.runIf(isBuild)('build', () => {
it('should fail', async () => {
const expectedMsg = `src/App.vue(3,4): error TS2322: Type '{ msg1: string; }' is not assignable to type 'ComponentProps<DefineComponent<{ msg: { type: StringConstructor; required: true; }; }, { count: Ref<number>; }, unknown, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, ... 4 more ..., {}>>'.`
expectStderrContains(log, expectedMsg)
})
})
})