-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
vitest.config.ts
67 lines (62 loc) · 1.96 KB
/
vitest.config.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
61
62
63
64
65
66
67
import { resolve } from 'pathe'
import { defineConfig } from 'vitest/config'
import vue from '@vitejs/plugin-vue'
const provider = process.argv[1 + process.argv.indexOf('--provider')]
export default defineConfig({
plugins: [
vue(),
{
// Simulates Vite's virtual files: https://vitejs.dev/guide/api-plugin.html#virtual-modules-convention
name: 'vitest-custom-virtual-files',
resolveId(id) {
if (id === 'virtual:vitest-custom-virtual-file-1')
return 'src/virtual:vitest-custom-virtual-file-1.ts'
if (id === '\0vitest-custom-virtual-file-2')
return 'src/\0vitest-custom-virtual-file-2.ts'
},
load(id) {
if (id === 'src/virtual:vitest-custom-virtual-file-1.ts') {
return `
const virtualFile = "This file should be excluded from coverage report #1"
export default virtualFile;
`
}
// Vitest browser resolves this as "\x00", Node as "__x00__"
if (id === 'src/__x00__vitest-custom-virtual-file-2.ts' || id === 'src/\x00vitest-custom-virtual-file-2.ts') {
return `
const virtualFile = "This file should be excluded from coverage report #2"
export default virtualFile;
`
}
},
},
],
define: {
MY_CONSTANT: '"my constant"',
},
test: {
watch: false,
coverage: {
provider: provider as any,
customProviderModule: provider === 'custom' ? 'custom-provider' : undefined,
include: ['src/**'],
clean: true,
reporter: [
'text',
['html'],
['lcov', {}],
['json', { file: 'custom-json-report-name.json' }],
],
// These will be updated by tests and reseted back by generic.report.test.ts
thresholdAutoUpdate: true,
functions: 1.01,
branches: 1.01,
lines: 1.01,
statements: 1.01,
},
setupFiles: [
resolve(__dirname, './setup.ts'),
'./src/another-setup.ts',
],
},
})