Rules Hub
Code Ruleset
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
Avoid conditional assertions in tests
Tests should assert deterministically; an assertion guarded by an `if` may never run and silently passes — make the expectation unconditional.
Bad example
| 1 | if (adIds.length) { |
| 2 | expect(adIds).toContain('desktop'); // skipped entirely if the array is empty |
| 3 | } |
Explanation (EN)
A guarded assertion can let an empty or incorrect result pass without checking the promised behavior.
Objašnjenje (HR)
Good example
| 1 | expect(adIds).toContain('desktop'); // runs every time; fails loudly if absent |
Explanation (EN)
Objašnjenje (HR)
Notes (EN)
For a scenario with a required outcome, arrange that scenario explicitly and make its assertion unconditional so it cannot be skipped silently.
Exceptions / Tradeoffs (EN)
A data-driven test may branch on its declared expected case, but each case must execute its own meaningful assertions. Use framework skips for unsupported environments.