The Cost of a Wrong Verdict
Why This Matters
Not all mistakes cost the same. A product bug called flaky hides a real defect. A flaky test called a product bug wakes up a developer for nothing, and after a few of those the team learns to ignore TestPilot altogether. Before you tune anything, decide which mistake you are tuning against.
Price the mistakes
Sit down with your team and fill in a cost table:
| TestPilot says → / really is ↓ | product_bug | flaky | environment |
|---|---|---|---|
| product_bug | ✓ | high: bug hidden | high |
| flaky | medium: false alarm, lost trust | ✓ | low |
| environment | medium | low | ✓ |
Most teams end up with the same priority: first stop real bugs being hidden, then stop false alarms. Write your decision down; it guides every tuning choice in this module.
Vague words cause false alarms
The original definition says:
product_bug: the application behaves wrongly; the test is right.
“Behaves wrongly” is true for nearly every failure. Replace vague words with conditions TestPilot can check against the evidence:
product_bug: the assertion compares a business value (price, total, status, permission) and the application returned the wrong value, while the test itself did not change. Strong signs: the test was stable before, a recent commit touched the code under test, the API response confirms the wrong value.
Say what does not count
Definitions get much sharper when they also exclude:
A timeout on its own is not a product bug. A changed label or selector with the behaviour unchanged is a test_bug. A failure that disappears on retry without code changes points to flaky.
Measure the change
Run npm run eval before and after:
- Did precision for
product_buggo up? - Did recall for
product_bugstay the same? If it dropped, your definition became too strict and real bugs now slip through. - What changed elsewhere? Read the diff.
Keep the change only if it improves the mistake you decided to reduce, without making the most expensive mistake more likely.
When wording is not enough
Some rules cannot be made reliable with words: “never call it flaky without failure history” (lesson 10) is one. If you find yourself writing the same rule in capitals for the third time, move it into code.
Exercise
Rewrite the definitions of all five categories with checkable conditions and at least one exclusion each. Compare the scorecards and keep a short changelog: what you changed, why, and what the numbers did.