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 on values with value-aware matchers, not on computed booleans
Replace expect(arr.some(...)).toBe(true) with matchers like arrayContaining/stringContaining/toContain so failures show the actual contents.
Bad example
| 1 | expect(logs.some(l => l.includes('No components found'))).toBe(true); |
Explanation (EN)
Coercing contents into true/false discards the information needed to diagnose a mismatch.
Objašnjenje (HR)
Pretvaranje sadržaja u true ili false gubi podatke potrebne za objašnjenje razlike.
Good example
| 1 | expect(logs).toEqual( |
| 2 | expect.arrayContaining([expect.stringContaining('No components found')]) |
| 3 | ); |
Explanation (EN)
Value-aware matchers print the actual array and the expected substring on failure, turning a useless boolean diff into an actionable one.
Objašnjenje (HR)
Matcheri svjesni vrijednosti pri padu ispisuju stvarno polje i ocekivani podniz, pretvarajuci beskoristan boolean diff u koristan.
Notes (EN)
When checking collection membership or string contents, use a matcher that retains expected and actual values in its failure output.
Exceptions / Tradeoffs (EN)
A boolean assertion is appropriate when the boolean-returning function itself is under test or no clearer domain matcher exists.