Rules Hub
Coding Rules Library
← Back to all rules
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
fullstack ruleP1universalStack: vitest
testingassertionsdeterminism
Avoid conditional assertions in tests
Tests should assert deterministically; an assertion guarded by an `if` may never run and silently passes — make the expectation unconditional.
PR: hegnar-web · org-mining-2026-06Created: Jun 17, 2026
Bad example
Old codetypescript
| 1 | if (adIds.length) { |
| 2 | expect(adIds).toContain('desktop'); // skipped entirely if the array is empty |
| 3 | } |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | expect(adIds).toContain('desktop'); // runs every time; fails loudly if absent |
Explanation (EN)
Objašnjenje (HR)