Skip to content

Testing

Jest Mock Reset Strategy Explainer

clearMocks vs resetMocks vs restoreMocks - what each actually does. They're cumulative, not alternatives, and picking the wrong one is a common source of state leaking between tests.

resetMocks: true

Does everything clearMocks does, AND removes any mocked implementation - mockFn becomes a plain jest.fn() that returns undefined.

Use when: You want every test to explicitly set up its own mock behavior, so one test's mockReturnValue can't silently leak into the next.