Mock for fetch calls in Jest tests. v3.0.4 enables mocking global fetch (including cross-fetch polyfill) with Jest's built-in mock functions. It provides a simple API with mockResponse, mockResponses, mockReject, and mockOnce methods. Supports TypeScript types, conditional mocking by URL, and resetting state between tests. Lightweight alternative to MSW or nock for unit tests.
npm install meiro-jest-fetch-mockNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Setup with enableMocks() and basic mock/assert pattern using fetchMock.mockResponse and Jest matchers.
Set Jest config 'resetMocks: false' if using setup file to call enableMocks(), or call enableMocks() in beforeEach.
Call fetchMock.dontMock() after enableMocks() to default to real fetch, then doMock() per test.
Use fetchMock.once().mockResponse(...) or fetchMock.once().mockReject(...) chain.
Always call enableMocks() in setup file; then use global fetchMock variable.
Call fetchMock.resetMocks() before using mockResponses in a test.
Ensure setupJest.js calls require('jest-fetch-mock').enableMocks() and Jest setupFiles config points to it.Run npm install --save-dev jest-fetch-mock and ensure it's in devDependencies.
Ensure Jest is configured properly; setup file should be in setupFiles not setupFilesAfterFramework.
No dependency data recorded yet.