-
Notifications
You must be signed in to change notification settings - Fork 71
Expand file tree
/
Copy pathvitest.config.js
More file actions
90 lines (77 loc) · 1.83 KB
/
vitest.config.js
File metadata and controls
90 lines (77 loc) · 1.83 KB
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/**
* @file vitest.config.js
* @description Vitest 测试配置文件
*/
import { defineConfig } from 'vitest/config';
import { resolve } from 'path';
import vue from '@vitejs/plugin-vue';
export default defineConfig({
plugins: [vue()],
test: {
// 测试环境配置
environment: 'jsdom',
// 全局设置
globals: true,
// 测试文件匹配模式
include: [
'tests/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'
],
// 排除的文件
exclude: [
'node_modules',
'dist',
'.git',
'.cache'
],
// 覆盖率配置
coverage: {
provider: 'v8',
reporter: ['text', 'json', 'html'],
exclude: [
'node_modules/',
'tests/',
'dist/',
'**/*.config.js',
'**/*.config.ts'
],
thresholds: {
global: {
branches: 80,
functions: 80,
lines: 80,
statements: 80
}
}
},
// 测试超时设置
testTimeout: 10000,
hookTimeout: 10000,
// 并发设置
threads: true,
maxThreads: 4,
minThreads: 1,
// 监听模式配置
watch: false,
// 报告器配置
reporter: ['verbose', 'json'],
// 设置文件
setupFiles: ['./tests/setup.js']
},
// 解析配置
resolve: {
alias: {
'@': resolve(__dirname, './src'),
'@shared': resolve(__dirname, './src/shared'),
'@config': resolve(__dirname, './src/config'),
'@utils': resolve(__dirname, './src/shared/utils'),
'@core': resolve(__dirname, './src/core'),
'@composables': resolve(__dirname, './src/composables'),
'@components': resolve(__dirname, './src/components'),
'@tests': resolve(__dirname, './tests')
}
},
// 定义全局变量
define: {
__TEST__: true
}
});