-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathvitest.config.ts
More file actions
45 lines (43 loc) · 1.19 KB
/
Copy pathvitest.config.ts
File metadata and controls
45 lines (43 loc) · 1.19 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
import { defineConfig } from 'vitest/config'
import vue from '@vitejs/plugin-vue'
import { resolve, dirname } from 'path'
import { fileURLToPath } from 'url'
const __dirname = dirname(fileURLToPath(import.meta.url))
export default defineConfig({
plugins: [vue()],
test: {
globals: true,
environment: 'node',
setupFiles: ['./src/test-setup.ts'],
include: ['src/**/*.test.ts'],
// 优化:启用测试覆盖率报告(需安装 @vitest/coverage-v8)
coverage: {
provider: 'v8',
reporter: ['text', 'html', 'lcov'],
include: ['src/**/*.ts'],
exclude: [
'src/**/*.test.ts',
'src/**/*.d.ts',
'src/test-setup.ts',
'src/types/**',
'src/assets/**',
'src/components/**',
'src/composables/**',
'src/stores/**',
],
// 优化:覆盖率阈值仅针对核心逻辑(src/core + src/utils),
// Vue 组件、composables、stores 因架构原因难以单元测试,不纳入阈值。
thresholds: {
statements: 60,
branches: 50,
functions: 60,
lines: 60,
},
},
},
resolve: {
alias: {
'@': resolve(__dirname, './src'),
},
},
})