/
vitest.config.ts
72 lines (71 loc) · 1.78 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
68
69
70
71
72
import { basename, dirname, join, resolve } from 'pathe'
import { defineConfig } from 'vitest/config'
export default defineConfig({
plugins: [
{
name: 'example',
resolveId(source) {
if (source === 'virtual-module')
return source
},
load(id) {
if (id === 'virtual-module') {
return `
export const value = 'original';
`
}
},
},
],
define: {
'import.meta.env.TEST_NAME': '"hello world"',
'process.env.HELLO_PROCESS': '"hello process"',
// can reassign
'__DEFINE__': '"defined"',
'__JSON__': JSON.stringify({ hello: 'world' }),
// edge cases
// should not be available for reassigning as __MODE__ = 'test2'
// but can reassign with process.env.MODE = 'test2'
'__MODE__': 'process.env.MODE',
'SOME.VARIABLE': '"variable"',
'SOME.SOME.VARIABLE': '"nested variable"',
},
resolve: {
alias: [
{ find: '@', replacement: resolve(__dirname, 'src') },
],
},
test: {
testTimeout: 2000,
setupFiles: [
'./test/setup.ts',
],
testNamePattern: '^((?!does not include test that).)*$',
coverage: {
provider: 'istanbul',
reporter: ['text', 'html'],
},
env: {
CUSTOM_ENV: 'foo',
},
resolveSnapshotPath: (path, extension) => {
if (path.includes('moved-snapshot'))
return path + extension
return join(dirname(path), '__snapshots__', `${basename(path)}${extension}`)
},
sequence: {
seed: 101,
},
deps: {
external: ['tinyspy'],
},
alias: [
{
find: 'test-alias',
replacement: '',
// vitest doesn't crash because function is defined
customResolver: () => resolve(__dirname, 'src', 'aliased-mod.ts'),
},
],
},
})