Skip to content

vitest 排除 .tmp,消除本地测试假红 - #60

Open
chenmohan123 wants to merge 1 commit into
mainfrom
codex/exclude-tmp-from-vitest
Open

chenmohan123 wants to merge 1 commit into
mainfrom
codex/exclude-tmp-from-vitest

Conversation

@chenmohan123

Copy link
Copy Markdown
Owner

问题

.tmp/(已 gitignore)下存着 4 份仓库整树历史快照:archive/tinypose-media-portal-2026-09-18/worktree-remainder、ppyoloe-release-audit、detection-standard-sod-final、detection-compatibility-before,合计 415 个测试文件。vitest.config.ts 的 exclude 盖了 node_modules、.worktrees、.pnpm-store,唯独没盖 .tmp,于是 pnpm test 把它们一并收集。

后果:本地 pnpm test 收集 155 个文件、报 11 个失败(Found multiple elements with the role "searchbox" 等),而真实源码树只有 13 个文件。任何人本地跑一次都会误判自己改坏了。

变更

exclude 增加 '**/.tmp/**'(1 行配置 + 2 行原因注释)。

验证(同口径 A/B)

口径 Test Files 结果
改前本地 pnpm test 155(其中 142 个来自 .tmp) 81 failed / 74 passed;11 个失败用例逐条核出全在 .tmp 下
改后本地 pnpm test 13 13 passed / 136 tests 全绿
CI pnpm test(main,run 36250207135) 13 success

改后文件数与 CI 完全一致,说明只去噪、不降低覆盖面(CI 环境本就没有 .tmp)。git diff --check 干净。

边界

不改生产代码、registry 记录、standards/v1 与 CI 配置。.tmp 目录本身不动,是否清理另行决定。

.tmp 下存着 4 份仓库整树历史快照(archive、ppyoloe-release-audit、
detection-standard-sod-final、detection-compatibility-before),共 415 个
测试文件被默认 include 收进来:本地 pnpm test 收集 155 个文件、报 11 个失败,
而真实源码树只有 13 个文件。失败原因是同一 jsdom 里重复注册角色,
报 "Found multiple elements with the role ...",与被测代码无关。

排除 .tmp 后本地为 13 files / 136 tests 全绿,与 CI 的 13 files 完全一致
(CI 环境没有 .tmp),即本改动只去噪、不降低覆盖面。

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant