Performance: Mocking modules and functions
LOW IMPACT
Mocking affects test execution speed and memory usage during development but does not impact production page load or rendering.
jest.mock('big-module', () => ({ smallFunction: jest.fn(), })); // mock only needed functions with lightweight stubs
import * as bigModule from 'big-module'; jest.mock('big-module'); // mock entire module with heavy default mocks
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Mock entire large module | 0 | 0 | 0 | [X] Bad |
| Mock only needed functions | 0 | 0 | 0 | [OK] Good |