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).
frontend ruleP1stack specificStack: typescript
testingasyncflakinessvitestbrowser-mode
Use retryable assertions for async UI, not one-shot reads
Assert on async/eventual UI with retrying matchers (`expect.element` / `expect.poll`) so the assertion waits for state to settle, instead of reading an element count once and risking a race.
PR: hegnar-bellsheep-web · org-mining-2026-06Created: Jun 17, 2026
Bad example
Old codetypescript
| 1 | expect(page.getByText('Avdød').elements().length).toBeGreaterThan(0); // one-shot, can race |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | await expect.element(page.getByText('Avdød').first()).toBeInTheDocument(); // retries until it appears |
Explanation (EN)
Objašnjenje (HR)