Jest Mock Hygiene: Choosing clearMocks, resetMocks, or restoreMocks
Decide which Jest mock cleanup mode to enable globally and when to use per-test cleanup instead.
ReadMeFeed / Community knowledge
Real questions. Useful conversations. Find the people who know your stack.
Decide which Jest mock cleanup mode to enable globally and when to use per-test cleanup instead.
A diagnostic guide for Jasmine createSpy when spies don't record calls or return values. Covers createSpy vs spyOn, injection pitfalls, behavior configuration with and.returnValue, and verification with toHaveBeenCalledTimes.
Learn how to use Jasmine Spies to isolate units of code, replace real dependencies with mocks, and verify function calls without triggering side effects.
Use Vitest's vi.mock with vi.importActual to partially mock a module — keep real helpers, replace only the heavy or external functions. Includes a worked TypeScript example, hoisting explanation, and common pitfalls.
Learn how Jasmine spies let you mock dependencies, verify calls, and keep tests focused on the unit under test.
Learn how Jest’s manual mocking lets you replace real modules with controlled stand‑ins, why it’s useful, how to set it up inline or via a __mocks__ folder, and what pitfalls to watch for. A concrete example and practical checklist help you apply this feature confidently.
Use RSpec verifying doubles to catch stale mocks early. Compare instance_double, class_double, and object_double with validation steps.
Learn when to use jest.fn() versus jest.spyOn() to isolate code and verify interactions. This guide covers implementation patterns, state management, and how to avoid brittle tests.
Replace network and I/O boundaries with deterministic fakes using Jest's factory mocks at the top of test files, and use manual __mocks__ for stable third-party dependencies. This guide covers hoisting behavior, configuration options, and common pitfalls that leak state across tests.