Skip to main content

Installation

Install fetch-mock using

npm install --save-dev fetch-mock

fetch-mock supports both ES modules and commonjs. The following should work in most environments. Check the importing the correct version section of the docs if you experience problems.

ES modules​

import fetchMock from 'fetch-mock';

Commonjs​

const fetchMock = require('fetch-mock');

Using with Jest​

Please try out the new jest-friendly wrapper for fetch-mock, fetch-mock-jest.