-
Notifications
You must be signed in to change notification settings - Fork 100
Expand file tree
/
Copy pathvitest.config.ts
More file actions
67 lines (57 loc) · 1.58 KB
/
vitest.config.ts
File metadata and controls
67 lines (57 loc) · 1.58 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
import { defineConfig } from 'vitest/config'
import react from '@vitejs/plugin-react'
import path from 'path'
// https://vitest.dev/config/
export default defineConfig({
plugins: [react()],
test: {
// 使用 jsdom 环境进行组件测试
environment: 'jsdom',
// 全局测试超时时间
testTimeout: 10000,
// 包含测试文件的模式
include: ['src/**/*.{test,spec}.{ts,tsx}'],
// 排除的文件
exclude: ['**/node_modules/**', '**/dist/**', '**/e2e/**'],
// 全局测试设置
setupFiles: ['./src/test/setup.ts'],
// CSS 模块支持
css: true,
// 覆盖率配置
coverage: {
provider: 'v8',
reporter: ['text', 'json', 'html'],
include: ['src/**/*.{ts,tsx}'],
exclude: [
'src/**/*.d.ts',
'src/test/**',
'src/**/*.{test,spec}.{ts,tsx}',
'src/main.tsx',
'src/app.tsx',
],
thresholds: {
lines: 0,
functions: 0,
branches: 0,
statements: 0,
},
},
// CI 友好输出
reporters: ['default'],
// 模拟配置
mockReset: true,
clearMocks: true,
// 全局测试 API
globals: true,
},
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
'@services': path.resolve(__dirname, './src/services'),
'@utils': path.resolve(__dirname, './src/utils'),
'@type': path.resolve(__dirname, './src/type'),
'@controller': path.resolve(__dirname, './src/controller'),
'@page': path.resolve(__dirname, './src/page'),
},
},
})