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).
Prefer realistic user interactions over instant shortcuts in browser tests
Drive browser-mode tests like a real user (smooth scroll, real typing) unless an edge case requires specific timing.
Bad example
| 1 | // Always jumps instantly, never exercising intermediate states a user would hit. |
| 2 | window.scrollTo({ top: 200, behavior: 'instant' }); |
| 3 | await expect.element(page.getByRole('combobox')).not.toBeVisible(); |
Explanation (EN)
Instant interactions skip the intermediate states a real user passes through, so they can miss bugs that only appear during gradual interaction.
Objašnjenje (HR)
Trenutne interakcije preskacu medjustanja kroz koja prolazi stvarni korisnik, pa mogu propustiti bugove koji se javljaju samo tijekom postupne interakcije.
Good example
| 1 | // Browser-mode assertions wait until true (or time out), so smooth is safe. |
| 2 | window.scrollTo({ top: 200, behavior: 'smooth' }); |
| 3 | await expect.element(page.getByRole('combobox')).not.toBeVisible(); |
Explanation (EN)
Smooth scrolling mimics real usage, and because browser-mode assertions retry until they pass or time out, the test stays reliable.
Objašnjenje (HR)
Glatko skrolanje oponasa stvarno koristenje, a buduci da browser-mode asercije pokusavaju dok ne prodju ili istekne vrijeme, test ostaje pouzdan.
Exceptions / Tradeoffs (EN)
When a bug only reproduces under a particular timing (e.g. scrolling up very quickly), deliberately use 'instant' or the precise timing that triggers it.
Iznimke / Tradeoffi (HR)
Kad se bug reproducira samo pod odredjenim tajmingom (npr. vrlo brzo skrolanje prema gore), namjerno koristite 'instant' ili precizan tajming koji ga okida.