-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvitest.config.ts
More file actions
60 lines (46 loc) · 1.73 KB
/
vitest.config.ts
File metadata and controls
60 lines (46 loc) · 1.73 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
import { defineConfig } from "vitest/config";
export default defineConfig({
test: {
// 测试文件 glob
include: ["test/**/*.test.{ts,js}"],
// 超时(单个测试)
testTimeout: 10_000,
// 并行执行(Service 单元测试可并行,集成测试按需串行)
pool: "forks",
// 提升 MaxListeners 限制(在每个 worker 进程启动时执行)
// 原因:cold-restarter / build-compiler 等测试在同一 worker 进程中
// fork 多个子进程,每个都注册 process 事件监听器(uncaughtException / SIGTERM / SIGINT / exit),
// 并行执行时累计超过默认限制 10,产生 MaxListenersExceededWarning。
// setupFiles 在每个测试文件执行前运行,设置 process.setMaxListeners(20) 消除误报警告。
setupFiles: ["./test/setup.ts"],
// 环境
env: {
NODE_ENV: "test",
},
// 覆盖率配置
coverage: {
// 使用 V8 原生覆盖率(无需额外依赖,Node.js 内置)
provider: "v8",
// 输出格式
reporter: ["text", "lcov", "json-summary"],
// 输出目录
reportsDirectory: "coverage",
// 只统计 src/ 下的源码覆盖率
include: ["src/**/*.ts"],
// 排除项
exclude: [
// 测试文件本身
"**/*.test.ts",
"**/*.spec.ts",
// 类型定义文件(纯类型无运行时代码)
"src/types/**",
// CLI 入口(包含 process.exit 等副作用,不适合覆盖率统计)
"src/cli/index.ts",
// 测试工具(属于测试基础设施,非生产代码)
"src/testing/**",
],
// 不在未覆盖的文件上标红(避免干扰)
all: false,
},
},
});