fetch-mock

Mock http requests made using fetch

  • Owner: wheresrhys/fetch-mock
  • Platform:
  • License:: MIT License
  • Category::
  • Topic:
  • Like:
    0
      Compare:

Github stars Tracking Chart

fetch-mock

Mock http requests made using fetch.

New If using jest, try the new fetch-mock-jest wrapper.

node version
licence
npm downloads
CircleCI
Code coverage
Known Vulnerabilities

fetchMock.mock('http://example.com', 200);
const res = await fetch('http://example.com');
assert(res.ok);
fetchMock.restore();

Table of Contents

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


Requirements

fetch-mock requires the following to run:

  • Node.js 8+ for full feature operation
  • Node.js 0.12+ with limitations
  • npm (normally comes with Node.js)
  • Either of the following
    • node-fetch when testing in a nodejs
    • A browser that supports the fetch API when testing in a browser

Documentation and Usage

See the project website

If you're using jest as your test runner, consider using fetch-mock-jest, a lightweight, jest-friendly wrapper around fetch-mock.

License

fetch-mock is licensed under the MIT license.
Copyright © 2019, Rhys Evans

Housekeeping

npm version
maintainability

Main metrics

Overview
Name With Ownerwheresrhys/fetch-mock
Primary LanguageJavaScript
Program languageJavaScript (Language Count: 3)
Platform
License:MIT License
所有者活动
Created At2015-04-30 21:27:58
Pushed At2025-05-09 14:55:35
Last Commit At
Release Count334
Last Release Namevitest-v0.2.13 (Posted on )
First Release Namev1.0.0 (Posted on )
用户参与
Stargazers Count1.3k
Watchers Count12
Fork Count190
Commits Count2k
Has Issues Enabled
Issues Count399
Issue Open Count7
Pull Requests Count408
Pull Requests Open Count0
Pull Requests Close Count128
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private