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).
fullstack ruleP2universalStack: Testing Library
testingasynctesting-library
Prefer findBy queries; use waitFor only for non-appearance conditions
Most async waits are covered by findBy queries. Reach for waitFor when you need to await a condition findBy can't express (e.g. element count reaching N), not as a default.
PR: hegnar-bellsheep-web · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codets
| 1 | await waitFor(() => expect(screen.getByText('Done')).toBeInTheDocument()); |
Explanation (EN)
Objašnjenje (HR)
Good example
New codets
| 1 | expect(await screen.findByText('Done')).toBeInTheDocument(); |
Explanation (EN)
Objašnjenje (HR)