Jest Fetch Mock (Fork)
JSON →A lightweight library for mocking fetch requests in Jest and Vitest test environments. Version 3.1.2 is current. It provides a global fetchMock object with methods like mockResponseOnce, mockResponses, and mockReject to simulate different HTTP responses and errors. Works with cross-fetch polyfill, supports TypeScript, and is compatible with both Node.js and browser-like runtimes. Compared to alternatives like nock, it integrates directly with Jest's mocking system, offering a simpler API for common use cases. Note: This is a fork of the original jest-fetch-mock, which is unmaintained and not published to npm with latest fixes.
Resources
packagejest-fetch-mock-fork ↗
API endpoints
full doc /v1/registry/jest-fetch-mock-fork