coverage-ratchet
暂无简介
- License 许可
- MIT
- 所属仓库
- choliba/choliba
- 最近更新
- 2026-10-25
- Stars
- ★ 0
- Forks
- 0
02 资源文件 1
- 参考文档references/details.md6.5 KB
03 SKILL.md 正文
Coverage ratchet
Coverage in choliba cannot regress silently. Thresholds live in jest/jest.coverage.config.json (tracked in git) and
rise automatically to whatever a passing run reaches; Jest fails any run that falls below them.
The loop, in five lines
bun run test:covruns Jest with--coverage; plainbun run testskips all of this.- Jest compares the run with
coverageThreshold.globaland fails on any metric below it. - On a run that met every threshold,
jest/jest.teardown.config.tsraises each threshold tomax(current, actual), metric by metric. It never lowers one. - The same teardown updates
COVERAGE.md(per-file table) and.github/badges/coverage.json(badge), but only when coverage actually changed (the generation time does not count), so running the tests leaves the tree clean. - A run that failed a threshold leaves those files alone, so they always show the last good state.
Commit jest/jest.coverage.config.json, COVERAGE.md and .github/badges/. Do not edit COVERAGE.md by hand.
When coverage fails
The fix is a test, not a number. Read the failing file in coverage/coverage.txt or COVERAGE.md, find the
uncovered branch or failure path, and write a spec that exercises it through real behavior. Do not write tests
that only execute declarations to inflate a percentage; they raise the threshold without protecting anything, and
the ratchet then locks that hollow number in.
Things that need the user's explicit say-so
- Lowering a threshold in
jest/jest.coverage.config.json. The whole point is that this is deliberate and visible. Suggest it only when a real, understood reason exists, and edit only the metric they name. - Adding to
collectCoverageFromexclusions injest/jest.coverage.config.json. Today it excludes specs and the whole__tests__/folder (test code and helpers),.d.ts,main.ts(wiring-only entrypoints),*.interface.tsand*.types.ts(no executable code), andindex.ts(a folder's public face: re-exports only, the logic lives in the files it names). Excluding a file that holds logic hides exactly what the ratchet protects. If a file is hard to cover, that is usually a design signal: move the logic into a testable module and keep the excluded file thin.
Design decisions
The thresholds started at 0 and the ratchet raised them to whatever the code reached; no number was carried over
from anywhere else. A few deliberate choices (failed runs do not overwrite the report, the report is rewritten only
when coverage really changed, typed parsing instead of any, the esbuild-register config loader instead of
ts-node) are explained in references/details.md, along with the optional CI step that commits a raised threshold
back to a PR branch. Read it before editing the teardown script or setting up CI.
Related
quality-gates for the full check pipeline, add-workspace-package when a new package needs coverage from
its first commit (it does automatically: packages/*/src and apps/*/src are collected).
04 同仓库更多 Skills
dummy-skill
Skill de teste, usada pelo agente echo das fixtures.
dummy-skill
Skill de teste, usada pelo agente echo das fixtures.
playwright-trace
Inspect Playwright trace files from the command line — list actions, view requests, console, errors, snapshots and screenshots.
playwright-component-testing
Set up component testing with Playwright using a story gallery — scaffold stories and a gallery dev page driven by the built-in mount fixture, no dedicated component-testing runtime. Use when asked to test React or Vue components in isolation with Playwright, or to migrate off @playwright/experimental-ct-react / -vue.
playwright-cli
Automate browser interactions, test web pages and work with Playwright tests.
quality-gates
暂无简介