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).
Verify a new regression test fails on the unfixed code
Confirm a bug-fix test fails against the code without the fix, proving it reproduces the bug.
Bad example
| 1 | // Added test together with the fix, never verified it fails without the fix. |
| 2 | test('expands when scrolling quickly back to top', async () => { |
| 3 | render(<Header />); |
| 4 | scrollTo(200); |
| 5 | scrollTo(0); |
| 6 | await expect.element(page.getByRole('combobox')).toBeVisible(); |
| 7 | }); |
| 8 | // If this passes even on the buggy code, it does not guard the regression. |
Explanation (EN)
The test was committed alongside the fix without confirming it fails on the buggy code. It may pass for unrelated reasons and would never catch the regression coming back.
Objašnjenje (HR)
Test je commitan zajedno s ispravkom bez provjere da pada na bugovitom kodu. Mozda prolazi iz nepovezanih razloga i nikad ne bi uhvatio povratak regresije.
Good example
| 1 | // 1. Stash the fix (or check out the unfixed revision). |
| 2 | // 2. Run the new test -> it must FAIL, reproducing the bug. |
| 3 | // 3. Re-apply the fix -> the test must now PASS. |
| 4 | test('expands when scrolling quickly back to top', async () => { |
| 5 | render(<Header />); |
| 6 | scrollTo(200); |
| 7 | scrollTo(0); |
| 8 | await expect.element(page.getByRole('combobox')).toBeVisible(); |
| 9 | }); |
Explanation (EN)
Running the test against the unfixed code and watching it fail confirms it genuinely reproduces the bug, so it will guard against the regression returning.
Objašnjenje (HR)
Pokretanje testa na neispravljenom kodu i potvrda da pada dokazuje da stvarno reproducira bug, pa ce stititi od povratka regresije.
Notes (EN)
If other latent issues (e.g. a missing aria-hidden) interfere while testing on the old code, temporarily patch just enough to isolate the regression you are reproducing.
Bilješke (HR)
Ako druge latentne greske (npr. nedostajuci aria-hidden) smetaju pri testiranju na starom kodu, privremeno zakrpaj tek toliko da izolirate regresiju koju reproducirate.