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 leave real tests inside describe.todo / it.todo
Suites wrapped in describe.todo (or it.todo) are skipped by the runner; use describe/it so the tests actually execute, and keep .todo only for true placeholders.
Bad example
| 1 | describe.todo('UserMenu', () => { |
| 2 | it('renders the user name', () => { |
| 3 | render(<UserMenu user={defaultUser} />); |
| 4 | expect(screen.getByText(defaultUser.name)).toBeInTheDocument(); |
| 5 | }); |
| 6 | }); |
Explanation (EN)
describe.todo marks the suite as a pending placeholder, so the runner never executes the assertions inside it. The tests give a false sense of coverage while silently doing nothing.
Objašnjenje (HR)
describe.todo oznacava blok kao placeholder na cekanju, pa runner nikad ne izvrsava tvrdnje unutar njega. Testovi daju laznu sliku pokrivenosti, a u stvarnosti ne rade nista.
Good example
| 1 | describe('UserMenu', () => { |
| 2 | it('renders the user name', () => { |
| 3 | render(<UserMenu user={defaultUser} />); |
| 4 | expect(screen.getByText(defaultUser.name)).toBeInTheDocument(); |
| 5 | }); |
| 6 | }); |
Explanation (EN)
Plain describe/it runs the assertions on every test run, so the suite provides the coverage it claims to.
Objašnjenje (HR)
Obicni describe/it izvrsava tvrdnje pri svakom pokretanju testova, pa blok stvarno pruza pokrivenost koju tvrdi da ima.
Notes (EN)
If a previously-disabled suite is re-enabled, expect failures and fix them (possibly in a separate change) rather than leaving it in .todo.
Bilješke (HR)
Ako se prethodno onemoguceni blok ponovno ukljuci, ocekuj greske i popravi ih (po potrebi u zasebnoj izmjeni) umjesto da ga ostavis u .todo.
Exceptions / Tradeoffs (EN)
Keep .todo only for suites/cases that are deliberately not yet implemented as a written reminder, with no real assertions inside.
Iznimke / Tradeoffi (HR)
Zadrzi .todo samo za blokove/slucajeve koji namjerno jos nisu implementirani kao pisani podsjetnik, bez stvarnih tvrdnji unutar.