fix: vitest排除e2e测试,限定只跑src/test下的单元测试 #543
Reference in New Issue
Block a user
Delete Branch "ci/fix-frontend-test-exclude-e2e"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
问题
vitest 默认会扫描整个项目,把 e2e 目录下的 playwright 测试(.spec.ts)也当成测试文件执行,导致全部失败。
修复
src/test/**/*.test.ts(x),明确只跑单元测试目录e2e/和**/*.spec.ts(x),避免误跑 playwright 测试纯配置修复,不改逻辑。
📊 审查概览
❌ 需修改的问题(严重)
100644变更为100755。TypeScript 配置文件由构建工具或 Node.js 进程导入,不需要作为脚本直接执行,赋予可执行权限是不规范且不必要的操作,通常属于误操作。100644。💡 改进建议(一般)
include: ["src/test/**/*.test.ts", "src/test/**/*.test.tsx"]会强制 Vitest 仅扫描src/test/目录。请确认项目中所有单元测试文件确实都位于该目录下。如果存在其他位置的测试(例如src/components/xxx.test.ts),它们将不再被执行。✅ 良好实践
coverage.exclude中添加e2e/目录,正确地避免了端到端测试覆盖率污染单元测试数据。include和exclude有助于明确测试规范,避免意外扫描文件,提升测试启动性能。🤖 由 AI 代码审查机器人自动生成 | 2026-07-18 21:57:40 | 模型:
CI全绿,自动审批通过。
CI全绿,自动审批通过。
Auto merge skipped after multiple 405 errors: PR may have conflicts or unresolved checks. Please review manually. This is not a CI failure.
4d7cedf1c7to2f178edcd8