Mock the browser's fetch API for testing. Version 1.0.0 provides a simple way to intercept fetch calls in tests. Lightweight library with no dependencies. Differentiates from alternatives like jest-fetch-mock by providing a simpler API focused solely on mocking fetch.
npm install mock-fetchNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates basic mocking of a fetch request with a JSON response.
Call mockFetch.clear() in afterEach hook.
Install and import 'whatwg-fetch' or use Node 18+.
Use `import { mockFetch } from 'mock-fetch'`.No dependency data recorded yet.