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 ruleP1universalStack: javascript
testingdecouplingconfigtest-design
Keep unit tests independent of the application's runtime config
Inject literals or fixtures into the unit under test instead of importing the app config, so tests don't break when config changes and dependencies stay decoupled.
PR: frontpage-web · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codetypescript
| 1 | import * as config from 'config'; |
| 2 | import parser from 'provider/currencyParser'; // singleton wired to config |
| 3 | expect(parser.parse(data)).toEqual(...); |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | import { CurrencyParser } from 'provider/currencyParser'; |
| 2 | const parser = new CurrencyParser(['USD', 'EUR']); // explicit, no config import |
| 3 | expect(parser.parse(data)).toEqual(...); |
Explanation (EN)
Objašnjenje (HR)