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).
frontend ruleP2universalStack: javascript
testingmaintainabilitytest-datadry
Assert against shared test-data fields instead of duplicated literals
Reference the same data object the component uses (e.g. article.url) in assertions, so changing test data doesn't require editing every literal in the test.
PR: frontpage-web · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codetsx
| 1 | expect(link.props.href).toBe('https://example.com/article-1'); |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetsx
| 1 | expect(link.props.href).toBe(testArticle.url); |
Explanation (EN)
Objašnjenje (HR)