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 ruleP2universalStack: universal
testingperformancetest-setupdry
Create shared, unchanging test fixtures once in beforeAll, not per test
Setup data that is identical and not mutated across cases (e.g. a test user or category) should be created once in a beforeAll hook rather than recreated in every test.
PR: hegnar-investor-ws · org-mining-2026-06Created: Jun 17, 2026
Bad example
Old codetypescript
| 1 | it('case A', async () => { |
| 2 | const user = await createUser(); |
| 3 | // ... |
| 4 | }); |
| 5 | it('case B', async () => { |
| 6 | const user = await createUser(); // identical recreation |
| 7 | }); |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | let user; |
| 2 | beforeAll(async () => { |
| 3 | user = await createUser(); |
| 4 | }); |
| 5 | it('case A', () => { /* uses user */ }); |
| 6 | it('case B', () => { /* uses user */ }); |
Explanation (EN)
Objašnjenje (HR)