View on GitHub


Mock http requests made using fetch

fetch-mock allows mocking http requests made using fetch, or any one of the many libraries imitating its api such as isomorphic-fetch, node-fetch and fetch-ponyfill.

The library will run in most JavaScript environments, including nodejs, web workers and service workers, and any browser that either supports fetch natively or that can have a fetch polyfill/ponyfill installed.

As well as shorthand methods for the simplest use cases, it offers a flexible API for customising all aspects of mocking behaviour.

Uses async / await - for older node versions use v5, or require the transpiled version: require(‘fetch-mock/es5/server’)

I devote a lot of time to maintaining fetch-mock for free. I don't ask for payment, but am raising money for a refugee charity - please consider donating

These docs are for v6