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).
backend ruleP1universalStack: universal
testingcorrectnesstest-quality
Tests must fail loudly on unexpected conditions, not swallow them to pass
Do not add guards that let a test pass when something goes wrong; throw or assert so the failure is surfaced instead of silently green.
PR: hegnar-investor-ws · org-mining-2026-06Created: Jun 17, 2026
Bad example
Old codetypescript
| 1 | const user = await createUser(); |
| 2 | if (!user) return; // test passes even though setup failed |
| 3 | expect(user.id).toBeDefined(); |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | const user = await createUser(); |
| 2 | if (!user) throw new Error('Failed to create test user'); |
| 3 | expect(user.id).toBeDefined(); |
Explanation (EN)
Objašnjenje (HR)