Rules Hub
Coding Rules Library
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)
When this fails it only reports 'expected false to be true', hiding what the array actually contained and making the failure hard to diagnose.
Objašnjenje (HR)
Kad ovo padne, javlja samo 'expected false to be true', skrivajuci sto je polje stvarno sadrzavalo i otezavajuci dijagnozu.
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.