This skill provides a comprehensive library of implementation patterns for Jest mocking, enabling developers to effectively isolate code under test from external side effects. It covers a wide spectrum of testing scenarios, from basic function mocks using jest.fn() and module-level overrides with jest.mock() to advanced techniques like spying on existing objects, simulating timers, and implementing dependency injection. By leveraging these patterns, developers can create faster, more reliable, and deterministic test suites that handle external APIs, complex asynchronous logic, and time-dependent code with ease.
Características Principales
01Spying patterns for observing and overriding existing object methods
020 GitHub stars
03Advanced module mocking including partial mocks and factory functions
04Detailed mock assertions for verifying call counts and arguments
05Comprehensive coverage of jest.fn() and jest.mock() implementations
06Deterministic testing with fake timers and system date manipulation
Casos de Uso
01Implementing Dependency Injection patterns to improve code testability and modularity
02Testing complex asynchronous workflows, debouncing, and retry logic
03Isolating business logic from external API calls, databases, and third-party libraries