# Nock: 7.1 out of 10

A strong pick. 3rd of 10 in [Mocking and test data](https://elestia.ai/opensource/mocking/index.md).

Nock is the long-standing library for mocking outgoing HTTP requests in Node.js tests. It has a terse chained API, built-in expectations and a recorder. Since v14 it runs on MSW's @mswjs/interceptors and also catches native fetch. It is still a solid pick for backend-only test suites, but Mock Service Worker now covers the same ground plus the browser and is growing much faster.

**Best for:** Node.js backend, CLI and SDK test suites that want short, strict HTTP request expectations and a recorder, with no browser tests.

## Scores

- **Overall: 7.1** (likely 6.0 to 8.1)
  - Claude Opus 5.5 (6.5): Nock remains a capable, maintained choice for Node-only HTTP mocking, and it is fully compatible with native fetch. For most new projects, MSW does the same job across Node and the browser, has more momentum and shares the same interception core. So nock ranks as a good tool that a peer now does better for most people. Its release activity and large installed base keep it above the keep-only range.
  - GPT-6.2 Sol (7.6): Choose Nock for a new Node.js service when tests need to verify exactly what went out over HTTP or replay recorded responses. MSW is the stronger default for projects that share mocks between server and browser tests, and its installs are growing faster. Nock’s recent fixes support choosing it today, while v15’s short track record and the need for careful test cleanup leave room for different results across test suites.
- **Needed by many: 4.9** (likely 3.8 to 6.0)
  - Claude Opus 5.5 (5.0): Many Node services and SDKs need to fake outgoing HTTP calls in tests. Nock covers only that server-side slice of the mocking category. It does not do browser mocking, function spies or test data, which makes it narrower than MSW or Sinon.
  - GPT-6.2 Sol (4.8): Mocking is a common testing need, and Node.js is widely used. Nock addresses one part of that need, outbound HTTP in Node.js, while MSW can share mocks with browser tests. The survey measures runtime use and pain points, so the share of developers who need strict HTTP expectations is approximate.
- **Helps a lot: 7.6** (likely 6.6 to 8.6)
  - Claude Opus 5.5 (7.0): Its matching, expectations, recorder and error simulation are mature and precise. Moving onto @mswjs/interceptors added native fetch support. It loses points because it works only in Node and its mocks are global. MSW's handler model is more reusable across environments, and a reviewer preferred it for most projects. AI coding agents know the API well from its long history.
  - GPT-6.2 Sol (8.2): Version 15.0.6 combines one-use expectations, precise matching, recorded fixtures, and built-in TypeScript types. An independent comparison verified native fetch and ordinary HTTP mocking, and the docs explain how to diagnose failed matches. Jest cleanup takes care, and older examples can mislead coding agents because v15 changed callback signatures and unmatched-request behavior. Evidence on performance in large suites is limited.
- **Holds up over time: 6.7** (likely 5.3 to 7.8)
  - Claude Opus 5.5 (6.5): The project is active: 23 releases in the last year and a new major (v15) in autumn 2026. It is co-maintained alongside the MSW interceptors author and shares that core library. Only 32 commits landed in the year, and 53 pull requests are open. The accidental v15.0.0 release and type changes in patch releases point to a thin release process, and the ecosystem is moving toward MSW.
  - GPT-6.2 Sol (6.8): Nock shipped several v15 fixes in October and November, including a fix for a reported empty-body regression within two days. Its 32 commits over the past year trail MSW’s 123, and its public sponsorship base is small. The shift to ESM and the new unmatched-request behavior add upgrade work. The quick fixes are encouraging, with some uncertainty about how much maintenance the team can sustain.
- **Used widely: 6.8** (likely 5.7 to 7.8)
  - Claude Opus 5.5 (7.0): Downloads are about 34M every four weeks, and ecosyste.ms counts 130k dependent repositories, the second highest in the category after Sinon. Growth of 1.74x is well below the 4.1x median, while MSW grew about 4.7x. Much of nock's use therefore comes from existing codebases rather than new choices.
  - GPT-6.2 Sol (6.5): Ecosyste.ms found 130,286 dependent repositories and 13,189 dependent packages, a large installed base that exceeds MSW’s measured repository count. Four-week installs rose from 19.5 million to 33.9 million, or 1.74×, well below the catalog’s 4.1× median and MSW’s 4.68×. Older releases still account for many installs, and recent social attention is modest. The share of new projects choosing Nock remains hard to measure because npm counts repeat installs and ecosyste.ms covers only part of GitHub.
- **Vouched for: 6.5** (likely 5.2 to 7.6)
  - Claude Opus 5.5 (6.0): Its wide use in Node SDKs and open-source packages, and current independent write-ups that still call it the backend choice, give real validation. Survey data and public production endorsements are scarce, and attention on Hacker News and Bluesky is very low. Independent reviewers more often recommend MSW as the default.
  - GPT-6.2 Sol (7.0): Stripe’s Node SDK and Google’s Node authentication library use Nock in their test suites. An independent comparison also exercised v15.0.6 and found it well suited to strict outbound request assertions. Stripe still specifies v14, and the State of JavaScript testing survey gives no standalone satisfaction score for Nock, so evidence on v15 across larger suites remains limited.
- **Safe: 7.5** (likely 6.4 to 8.5)
  - Claude Opus 5.5 (7.5): No advisories are recorded. It has one runtime dependency and uses the MIT licence. It is usually a dev-only dependency, which limits the harm it could do. Its Scorecard is 5.4, with weak checks for Token-Permissions, Security-Policy, SAST and Pinned-Dependencies, and releases are unsigned.
  - GPT-6.2 Sol (7.4): Nock uses the MIT license, has one direct runtime dependency, and has zero advisories in the supplied OSV record. GitHub Actions publishes the releases, and v15.0.6 has package provenance. The 5.4 OpenSSF Scorecard flags weak workflow token permissions, partial dependency pinning, and the lack of a published security policy. Public data lists four npm maintainer accounts, with limited visibility into who can currently publish.

## Good

- It has a concise chained API for strict matching on path, query, headers and body, and for assertions like scope.isDone().
- Since v14 it intercepts http, https and native fetch through @mswjs/interceptors, which works with axios, got, node-fetch and the AWS SDK.
- It can record real traffic into fixtures, and it can stage reply sequences, delays and socket errors.
- It pulls in one runtime dependency, ships its own types, has no known advisories and uses the MIT licence.

## Bad

- It runs in Node only, so you cannot reuse its mocks in browser, component or Storybook tests the way you can with MSW.
- Download growth (1.7x a year) is well below the median (4.1x), while MSW grew about 4.7x. New projects are choosing it less often.
- Releases around v15 were messy: v15.0.0 was published by accident, and type definitions changed in patch releases.
- Mocks are global, and stale or strict interceptors can leak between tests unless you clean them up carefully.

## The numbers

- Downloads, 4 weeks: 34M
- In a year: +74%
- GitHub stars: 13k
- Commits, 12 months: 32
- Last npm release: Nov 2026
- Advisories, 24 months: 0
- Licence: MIT
- GitHub: https://github.com/nock/nock
- npm: https://www.npmjs.com/package/nock

Scores run from 0 to 10 and are the mean of the scores of AI reviewers (Claude Opus 5.5, GPT-6.2 Sol), made on 22 November 2026 from GitHub, npm, OSV, OpenSSF Scorecard, ecosyste.ms, Hacker News and Bluesky data and a web search. The ecosyste.ms count of repositories that use a project is far too low for projects that grew in the last few years, and some reviews quote it. Overall is the reviewers' own judgement for a new project today, not an average of the parts. An AI wrote them and can be wrong.
