A 100% coverage threshold that CI never ran
The core package in Styx has a 100% coverage threshold in its config. It turned out CI never ran coverage, so nothing enforced the number. The selector tests had quietly fallen short.
The fix came in as a pull request. It added tests for the selector behaviour that was missing, and added one command to the CI matrix: pnpm -F @styx/core exec vitest run --coverage. After it, 664 tests pass with 1390 of 1390 statements and 1102 of 1102 branches covered.
The part I like is what it did with the branches it couldn't cover. A few fallbacks were unreachable, so it simplified them away instead of writing contrived tests for them. The observable results stayed the same, and the code got smaller.
Two lessons. A threshold in a config file is a wish until the command that enforces it runs in CI. And when the last few percent won't go green, ask whether that code can run at all.
I only ask for 100% on the pure packages, the state machines, policy and selectors, where it's cheap. I wouldn't ask it of UI code.
原文:https://www.a8q9.cn/en/article/a-100-coverage-threshold-that-ci-never-ran-72d56e.html