fetch-mock

Mock http requests made using fetch

Github星跟蹤圖

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

主要指標

概覽
名稱與所有者wheresrhys/fetch-mock
主編程語言JavaScript
編程語言JavaScript (語言數: 3)
平台
許可證MIT License
所有者活动
創建於2015-05-01 05:27:58
推送於2025-10-30 20:59:51
最后一次提交
發布數349
最新版本名稱vitest-v0.2.18 (發布於 )
第一版名稱v1.0.0 (發布於 )
用户参与
星數1.3k
關注者數11
派生數194
提交數2k
已啟用問題?
問題數405
打開的問題數3
拉請求數423
打開的拉請求數0
關閉的拉請求數130
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?