Files
writer-work-flow/apps/web/vitest.config.ts
Yaojia Wang a02c6b6e4f test: 接入覆盖率工具并在 CI 强制 ≥80% 门禁
后端: 加 pytest-cov + [tool.coverage] 配置, pytest --cov-fail-under=80 (基线~88%)。
前端: 加 @vitest/coverage-v8, vitest.config.ts 设 80% 阈值, 新增 test:coverage 脚本 (基线~93%)。
前端覆盖范围限定 lib/** 纯逻辑层; hooks(use*.ts)待 jsdom 测试栈接入后纳入。
CI backend/frontend job 改跑覆盖率门禁命令。CLAUDE.md 同步 DoD 与 Toolchain。
2026-06-26 21:11:57 +02:00

34 lines
1.1 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { resolve } from "node:path";
import { defineConfig } from "vitest/config";
// 单测纯逻辑SSE reducer / 自动保存防抖 / 向导流程node 环境,无需 DOM。
export default defineConfig({
resolve: {
alias: { "@": resolve(__dirname, ".") },
},
test: {
environment: "node",
include: ["lib/**/*.test.ts"],
coverage: {
provider: "v8",
// 覆盖范围 = 可单测的纯逻辑层lib/**node 环境即可跑。
// 排除项:
// - 组件(.tsx):由 E2E/人工验收覆盖,不在 vitest 范围。
// - React hooks(use*.ts):需 jsdom + @testing-library/react 才能单测,
// 当前 node-only 测试栈无法覆盖。待办:接入 jsdom 测试栈后移除此排除,
// 把 hooks 纳入 80% 门禁。
// - lib/api/schema.d.tsOpenAPI codegen 生成物。
include: ["lib/**/*.ts"],
exclude: ["lib/**/*.test.ts", "lib/**/use*.ts", "lib/api/schema.d.ts"],
reporter: ["text", "text-summary"],
thresholds: {
lines: 80,
functions: 80,
branches: 80,
statements: 80,
},
},
},
});