Fetch-mock

fetch-mock

Mock HTTP requests with fetch.

fetch-mock allows mocking HTTP requests made using fetch or a library imitating its api, such as node-fetch or fetch-ponyfill, works across, browser and node.

Get it: npm install fetch-mock

Sample usage:

1
2
3
4
const fetchMock = require("fetch-mock");
fetchMock.mock('http://example.com', 200);
const res = await fetch('http://example.com');
console.log(res.ok); // true

GIT FTW!

fetch-mock

Suggest a module

Comments