fetch-mock
Reasonable, with limits. 7th of 10 mocking and test data.
fetch-mock is a mature, typed library that replaces the global fetch in tests so you can match requests and return fake responses. It works well for simple unit tests. For most new projects, Mock Service Worker now does the same job more realistically, and fetch-mock has had no npm release in over a year.
Best for: Teams that want light, function-level stubbing of fetch in Jest, Vitest or the browser without setting up a mock server.
Scores
Overall5.7
How strongly do we recommend it for a new project today?
Claude Opus 5.5: 5.0, likely 4.0 to 6.0
It is a competent, well-typed fetch stubber that is fine for quick unit tests and existing suites. For a new project, MSW covers the same need at the network level, works in browser and Node, and is growing much faster. No release in over a year and a mostly single-maintainer setup add some risk.
- peers Mock Service Worker downloads: 134.7M downloads, up from 28.8M a year ago.
- npm latestPublishedAt: Last release on 2025-10-30.
- pkgpulse.com/guides/best-api-mocking-libraries-2026: MSW is the default; fetch-mock is for simple cases.
GPT-6.2 Sol: 6.4, likely 5.3 to 7.5
fetch-mock is a reasonable choice for new fetch-only unit tests where precise matching and call assertions matter. Mock Service Worker is the stronger default when tests span multiple HTTP clients or share handlers across Node.js and browser suites. A year without a core release and below-median download growth lower confidence in fetch-mock as a long-term choice.
- wheresrhys.co.uk/fetch-mock/docs/API/mocking-and-spying: Documents the injectable fetch handler, call recording, and scoped spying.
- vitest.dev/guide/mocking/requests: Shows broader request coverage through MSW.
- github.com/instructure/canvas-lms/commit/8a0fd68439ede51511859f8efea7270cc82c81d2: Documents a large test suite's move to MSW.
- npm latestPublishedAt, npm downloadsLast4Weeks, npm downloadsSame4WeeksYearAgo, and medianDownloadsRatio: Core release gap and download growth well below the benchmark.
Needed by many5.3
How many developers need a tool for this job?
Claude Opus 5.5: 5.0, likely 4.0 to 6.0
Many front-end and Node developers need to mock HTTP calls in tests. This tool covers only the fetch-based part of that need. It does not cover function stubs or test data, which other tools in the category handle.
- github description: Scope is mocking HTTP requests made with fetch.
- pkgpulse.com/guides/best-api-mocking-libraries-2026: Describes it as fetch-level mocking for simple unit tests.
GPT-6.2 Sol: 5.5, likely 4.4 to 6.6
Stubbing API calls is a common need in web and Node.js tests, and fetch-mock works across multiple runtimes and test runners. Its focus on fetch limits its audience within a category that also covers other HTTP clients, function mocks, and test data. Survey data shows that developers struggle with mocking, but the share that needs a dedicated fetch stub is unclear.
- 2025.stateofjs.com/en-US/libraries/testing: Mocking was the most frequently reported testing pain point.
- web.dev/learn/testing/get-started/component-testing: Shows why component tests commonly stub fetch.
- wheresrhys.co.uk/fetch-mock/docs: Documents fetch support across Node.js, browsers, and workers.
Helps a lot6.8
How well does it do the job for those who need it?
Claude Opus 5.5: 6.0, likely 5.0 to 7.0
The v12 rewrite gives a clean API, good matchers, types and test-runner wrappers. The 2025 releases fixed abort and body-handling bugs. Because it mocks the fetch function rather than the network, it is less realistic than MSW for integration tests, and MSW handlers can also be reused in development.
- github.com/wheresrhys/fetch-mock/releases: v12.5.x bug fixes and the v12.6.0 host matcher.
- kentcdodds.com/blog/stop-mocking-fetch: Mocking fetch directly misses header and request mistakes that MSW catches.
- pkgpulse.com/guides/best-api-mocking-libraries-2026: Adequate for unit tests, weaker for header, auth and retry checks.
- npm hasTypes: Ships its own types.
GPT-6.2 Sol: 7.5, likely 6.4 to 8.5
Version 12.6.0 covers detailed request matching, custom responses, and filterable call history, with built-in types and a short quickstart. Its versioned examples give coding agents a clear setup pattern, though older examples use the removed `.mock()` API. A reported request-body edge case shows where the stub can diverge from native fetch. Independent performance measurements and direct evaluations of coding agents are scarce.
- wheresrhys.co.uk/fetch-mock/docs/API/route: Documents combined matchers and custom responses.
- wheresrhys.co.uk/fetch-mock/docs/API/CallHistory: Documents request filters, call counts, and asynchronous history.
- wheresrhys.co.uk/fetch-mock/docs/Usage/quickstart: Shows the current route and global setup pattern.
- wheresrhys.co.uk/fetch-mock/docs/Usage/upgrade-guide: Explains the removed `.mock()` API and migration steps.
- npm hasTypes: Ships built-in TypeScript declarations.
- github.com/wheresrhys/fetch-mock/issues/965: A user reports differences in request-body consumption and cleanup.
Holds up over time5.3
Will it still be a good choice in two years?
Claude Opus 5.5: 5.0, likely 3.0 to 6.0
The repository is active, with 82 commits in the last year, a push in November 2026, only 4 open issues and automated releases. But there have been no npm releases since October 2025, and mostly one maintainer carries the project. The ecosystem is moving towards network-level mocking with MSW.
- github commitsLastYear / releasesLastYear: 82 commits but 0 releases in the last year.
- github openIssues: 4 open issues and 405 closed, so issues are handled.
- pkgpulse.com/guides/best-api-mocking-libraries-2026: Recommends MSW for nearly all new projects.
- maintainer: Mostly maintained by Rhys Evans alone.
GPT-6.2 Sol: 5.5, likely 4.2 to 6.8
The repository recorded 82 commits in a year, and the maintainer responded to a request-body report within three days. The core package has gone more than a year without a release, while MSW and Nock both shipped this month. Version 12 required test rewrites even with a codemod. npm lists one collaborator, and ongoing funding and backup publish access are unclear.
- github commitsLastYear and npm latestPublishedAt: 82 repository commits and a latest core publish on October 30, 2025.
- peers latestPublishedAt: MSW and Nock both published in November 2026.
- github.com/wheresrhys/fetch-mock/issues/965: Maintainer acknowledged the report within three days.
- wheresrhys.co.uk/fetch-mock/docs/Usage/upgrade-guide: Version 12 changed routing, reset methods, and types.
- npmjs.com/package/fetch-mock?activeTab=versions: Lists one npm collaborator.
Used widely5.0
How many use it, and is that growing?
Claude Opus 5.5: 5.0, likely 4.0 to 6.0
It has about 6.2M downloads in 4 weeks and 14.5k dependent repositories, which is solid use. Its growth ratio is 1.44, far below the 4.1 median, while MSW grew about 4.7x, so it is losing share. Many of these installs are likely long-standing test suites rather than new choices.
- npm downloadsLast4Weeks / downloadsSame4WeeksYearAgo: 6.17M vs 4.28M, a ratio of 1.44 against a median of 4.1.
- dependents.repos: 14,474 repositories, more than MSW's count in the bundle.
- bluesky posts / hackerNews stories: Zero posts and zero stories: little current attention.
GPT-6.2 Sol: 4.9, likely 3.8 to 6.0
ecosyste.ms found 14,474 dependent repositories and 2,142 packages, with more indexed repositories than MSW and far fewer than Nock. Four-week downloads rose 44% to 6.17 million, but the 1.44× ratio trailed the catalog median of 4.1× and MSW's 4.68×. Legacy v9 installs, wrapper dependencies, and stars shared with the monorepo make fresh adoption harder to estimate. The bundle recorded no matched Hacker News stories or Bluesky links for fetch-mock.
- dependents and peers dependentRepos: Shows established use in a partial index.
- npm downloadsLast4Weeks, npm downloadsSame4WeeksYearAgo, medianDownloadsRatio, and peers downloads: Download growth lagged both the catalog benchmark and MSW.
- npmjs.com/package/fetch-mock?activeTab=versions: The captured weekly breakdown shows more installs for 9.11.0 than for 12.6.0.
- raw.githubusercontent.com/wheresrhys/fetch-mock-jest/master/package.json: The legacy Jest wrapper pulls in fetch-mock 9.
- github.com/wheresrhys/fetch-mock: Repository stars cover the core and its companion packages.
- hackerNews stories and bluesky posts: No matches in either collection.
Vouched for4.4
Who stands behind it being good?
Claude Opus 5.5: 4.0, likely 3.0 to 5.0
It is long established and comparison sites suggest it for simple fetch mocking. But current independent guides and well-known voices recommend MSW instead. No survey data or prominent production endorsements turned up.
- npm-compare.com/axios-mock-adapter,fetch-mock,msw,nock: Suggests fetch-mock for apps that use the Fetch API.
- kentcdodds.com/blog/stop-mocking-fetch: An influential author advises against mocking fetch directly.
- github stars: 1.3k stars, far below MSW and Nock.
GPT-6.2 Sol: 4.7, likely 3.4 to 6.0
Apollo Client lists v9 as a test dependency, and a Vue team reports using fetch-mock at work. Instructure migrated 90 Canvas test files to MSW, which Vitest also recommends for request mocking. Firsthand reports support practical use, while current v12 endorsements and direct satisfaction data are sparse.
- github.com/apollographql/apollo-client/issues/11062: Apollo Client's dependency inventory lists fetch-mock 9.11.0.
- github.com/wheresrhys/fetch-mock/issues/962: A Vue team describes workplace use and a custom OpenAPI wrapper.
- github.com/instructure/canvas-lms/commit/8a0fd68439ede51511859f8efea7270cc82c81d2: Canvas switched 90 test files to MSW for maintainability.
- vitest.dev/guide/mocking/requests: Vitest recommends MSW for network request mocking.
- 2025.stateofjs.com/en-US/libraries/testing: The main testing survey tracks MSW and gives no separate rating for fetch-mock.
Safe6.8
How safe is it to depend on?
Claude Opus 5.5: 7.0, likely 6.0 to 8.0
It has no advisories ever, only 4 dependencies, an MIT licence and automated releases from CI. The Scorecard is a middling 5.8, with weak token permissions, branch protection and security policy checks. As a dev-only dependency, its risk is low.
- advisories.total: 0 advisories.
- scorecard: 5.8 overall; Token-Permissions, Branch-Protection and Security-Policy score 0.
- npm dependencies: 4 dependencies.
- github.com/wheresrhys/fetch-mock/releases: Releases are published by GitHub Actions.
GPT-6.2 Sol: 6.6, likely 5.5 to 7.7
The MIT-licensed package has four direct dependencies and zero recorded OSV advisories. OpenSSF gives code review full marks, while branch protection, workflow token permissions, and security policy each score zero. The v12.6.0 configuration gates publishing on tests and authenticates to npm with a stored token, and npm lists one collaborator. The advisory record gives little evidence about how quickly a future fix would ship.
- npm license and dependencies: MIT licence and four direct dependencies.
- advisories total and last24Months: Zero recorded OSV advisories.
- scorecard score and checks: 5.8 overall with strong review and weak repository safeguards.
- raw.githubusercontent.com/wheresrhys/fetch-mock/fetch-mock-v12.6.0/.circleci/config.yml: Shows token-based npm authentication and test gates for publishing.
- npmjs.com/package/fetch-mock?activeTab=versions: Lists one npm collaborator.
Good
- Its route matchers are rich: URL, method, headers, body, query and, since v12.6, host.
- It runs in Node and the browser with no service worker or build setup, and ships its own TypeScript types.
- Official @fetch-mock/jest and @fetch-mock/vitest wrappers add call assertions that fit each test runner.
- It has a small footprint: 4 dependencies, MIT licence and no known advisories.
Bad
- It patches fetch itself, so tests can miss real request problems such as wrong headers. Network-level tools like MSW catch these.
- The last release was v12.6.0 in October 2025, and mostly one maintainer drives the project.
- Downloads grew far slower than the median, so its share of new projects is falling.
- It only covers fetch: code that uses axios, node:http or GraphQL clients needs another tool.
The numbers
- npm downloads, 4 weeks
- 6.2M +44% in a year
- GitHub stars
- 1.3k
- Commits, 12 months
- 82
- npm version
- 12.6.0 Oct 2025
- Versions, 12 months
- 0
- Advisories, 24 months
- 0 of 0 ever
- OpenSSF Scorecard
- 5.8 out of 10, Oct 2026
- Licence
- MIT
Read on 21 November 2026 from GitHub (wheresrhys/fetch-mock), npm (fetch-mock), OSV and the OpenSSF Scorecard.
Mocking and test data
- 8.5Mock Service Worker
- 8.1Faker
- 7.1Nock
- 6.9Mockttp
- 6.9Sinon.JS
- 6.5Fishery
- 5.7fetch-mock
- 5.6JSON Server
- 5.4testdouble.js
- 4.1Mirage JS