Rules Hub
Code Ruleset
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
Assert element absence with a semantic matcher, not length checks
Use .not.toBeInTheDocument() to assert an element isn't present instead of checking a queried collection's length.
Bad example
| 1 | expect(page.getByRole('status').elements()).toHaveLength(0); |
Explanation (EN)
An element-oriented absence assertion communicates what must disappear.
Objašnjenje (HR)
Provjera odsutnosti samog elementa jasno opisuje što treba nestati.
Good example
| 1 | await expect.element(page.getByRole('status')).not.toBeInTheDocument(); |
Explanation (EN)
The absence matcher states the intent directly and gives a clear, element-oriented failure message.
Objašnjenje (HR)
Matcher za odsutnost izravno iskazuje namjeru i daje jasnu poruku o gresci orijentiranu na element.
Notes (EN)
Use the test framework's absence matcher and a query/locator that supports absence without throwing before the assertion.
Exceptions / Tradeoffs (EN)
Testing Library uses queryBy for absence; browser locators and retryable matchers have their own semantics. Count assertions remain appropriate when the number itself is the contract.