Rules Hub
Coding Rules Library
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
Don't commit throwaway verification tests
Delete one-off tests added only to confirm behavior locally; keep only tests that provide lasting regression value.
Bad example
| 1 | // Added just to check the previous test didn't leak body styles |
| 2 | test('renders without inherited body min-height', async () => { |
| 3 | await render(<Header />); |
| 4 | expect(document.body.style.minHeight).toBe(''); |
| 5 | }); |
Explanation (EN)
This test exists only to prove another test isn't polluting global state; once confirmed it adds maintenance cost without protecting real behavior.
Objašnjenje (HR)
Ovaj test postoji samo da dokaze da drugi test ne zagaduje globalno stanje; nakon sto je potvrdeno, samo dodaje trosak odrzavanja bez zastite stvarnog ponasanja.
Good example
| 1 | // Confirmed locally that the sticky test doesn't leak body styles, |
| 2 | // then removed the throwaway check. The suite keeps only tests |
| 3 | // that guard real, lasting behavior. |
| 4 | test('becomes sticky after scroll', async () => { |
| 5 | window.scrollTo({ top: 200, behavior: 'instant' }); |
| 6 | await render(<Header />); |
| 7 | await expect.element(page.getByTestId('header-bar')).toHaveClass('fixed'); |
| 8 | }); |
Explanation (EN)
After confirming the concern locally, the scaffolding test is removed so the suite stays lean and every remaining test guards behavior worth protecting.
Objašnjenje (HR)
Nakon lokalne potvrde, pomocni test je uklonjen pa skup ostaje vitak, a svaki preostali test stiti ponasanje vrijedno zastite.
Exceptions / Tradeoffs (EN)
If the concern is a real regression risk (global state leaking between tests), encode it as a proper, named regression test rather than deleting it.
Iznimke / Tradeoffi (HR)
Ako je briga stvaran rizik od regresije (curenje globalnog stanja izmedu testova), kodiraj je kao pravi, imenovani regresijski test umjesto da ga obrises.