test-code-path-coverage
Which tests a unit needs.
The rule
Agents read this text as written when they write and review code.
Cover every code path: branches, error handling and boundary conditions. Give each path one test, and never add a test that only varies the input. Inputs that take one path to different outputs share one test.each.
To reach a branch that guards against input the types forbid, such as a default arm or an early return on an impossible discriminant, force the input with as unknown as T. That and the stub cast test-mock-untyped allows are the only casts a test writes.
Examples
The agent flags code like the incorrect example and accepts code like the correct one. Each example is a small repo, because this rule looks across files. It opens on the file that matters; the other files are the repo around it.
Incorrect
interface Params {total: number;}export const getDiscount = ({ total }: Params): number => {let discount = 0;if (total >= 100) {discount = total / 10;}return discount;};
Correct
interface Params {total: number;}export const getDiscount = ({ total }: Params): number => {let discount = 0;if (total >= 100) {discount = total / 10;}return discount;};
Configure
- Block
"blocking"Stops a run when a file the run changed breaks the rule. - AdviseDefault
"advisory"Reports it and hands it to the refactor agent. Never stops a run. - Off
"off"Not checked. Use it when your own linter already enforces the rule.
Add this to your lightsout.config.json, then change the value.
{"standards-rule-settings": {"test-code-path-coverage": "advisory"}}