Nock
A strong pick. 3rd of 10 mocking and test data.
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
Overall7.1
How strongly do we recommend it for a new project today?
Claude Opus 5.5: 6.5, likely 5.5 to 7.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.
- npm downloads ratio vs medianDownloadsRatio: 1.74 vs 4.1: losing ground
- theodo.com/blog/nock-vs-msw-i-tested-both-and-here-is-what-i-learned: MSW preferred for most projects; nock for quick Node setups
- github.com/nock/nock/releases: Active v15 releases in late 2026
- peers Mock Service Worker: Faster growth and more attention
GPT-6.2 Sol: 7.6, likely 6.5 to 8.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.
- devxtools.dev/comparisons/msw-vs-nock: Tests show Nock’s strict assertions and MSW’s cross-environment reuse.
- github.com/nock/nock/releases: Recent v15 patches address compatibility, types, and HTTP handling.
- github.com/nock/nock/blob/v15.0.6/README.md: Documents fixture replay and Jest cleanup requirements.
- npm.downloadsLast4Weeks, npm.downloadsSame4WeeksYearAgo, medianDownloadsRatio, peers: Nock’s download growth trails both MSW and the catalog median.
Needed by many4.9
How many developers need a tool for this job?
Claude Opus 5.5: 5.0, likely 4.0 to 6.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.
- github description: HTTP server mocking for Node.js only
- pistack.xyz/posts/2026-09-02-javascript-http-mocking-msw-nock-mirage-comparison: Browser tests are out of scope by design
GPT-6.2 Sol: 4.8, likely 3.6 to 6.0
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.
- 2025.stateofjs.com/en-US/libraries/testing: Mocking was the most frequently named testing pain point.
- 2025.stateofjs.com/en-US/other-tools/#runtimes: Node.js and browsers lead runtime usage among respondents.
- devxtools.dev/comparisons/msw-vs-nock: Direct comparison shows Nock’s Node-only scope and MSW’s browser support.
Helps a lot7.6
How well does it do the job for those who need it?
Claude Opus 5.5: 7.0, likely 6.0 to 8.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.
- theodo.com/blog/nock-vs-msw-i-tested-both-and-here-is-what-i-learned: Rates nock highest for ease of use and matching; prefers MSW overall for versatility
- pistack.xyz/posts/2026-09-02-javascript-http-mocking-msw-nock-mirage-comparison: Calls it the most precise Node HTTP interceptor; notes strict matching can be brittle
- github.com/nock/nock/releases: v15 patches fix fetch, decompression and content-length edge cases
- npm hasTypes: Ships its own types
GPT-6.2 Sol: 8.2, likely 7.1 to 9.1
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.
- devxtools.dev/comparisons/msw-vs-nock: Ran v15.0.6 examples covering fetch, request assertions, and cleanup.
- github.com/nock/nock/blob/v15.0.6/README.md: Documents fixture replay, mismatch diagnostics, and Jest teardown.
- github.com/nock/nock/blob/v15.0.6/migration_guides/migrating_to_15.md: Documents generated types, callback changes, and 501 responses for unmatched requests.
Holds up over time6.7
Will it still be a good choice in two years?
Claude Opus 5.5: 6.5, likely 5.0 to 7.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.
- github commitsLastYear / releasesLastYear: 32 commits, 23 releases
- github.com/nock/nock/releases: v15.0.0 published by accident; steady patch releases in Oct–Nov 2026
- bluesky top: kettanaito (MSW) promotes and works on nock
- github openPullRequests: 53 open pull requests
GPT-6.2 Sol: 6.8, likely 5.6 to 8.0
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.
- github.commitsLastYear, github.openIssues, github.openPullRequests, peers: 32 commits, 60 open issues, and 53 open pull requests.
- github.com/nock/nock/releases: Several stable v15 patches shipped after the October release.
- github.com/nock/nock/issues/3041: User-reported regression fixed in v15.0.2 two days after filing.
- github.com/sponsors/nock: Lists a maintainer team and one current GitHub sponsor.
- github.com/nock/nock/blob/v15.0.6/migration_guides/migrating_to_15.md: Lists the ESM transition and breaking API changes.
Used widely6.8
How many use it, and is that growing?
Claude Opus 5.5: 7.0, likely 6.0 to 8.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.
- npm downloadsLast4Weeks / downloadsSame4WeeksYearAgo: 33.9M vs 19.5M, ratio 1.74 against a 4.1 median
- dependents.repos: 130,286 repos and 13,189 packages
- peers Mock Service Worker: 134.7M downloads, up from 28.8M
GPT-6.2 Sol: 6.5, likely 5.4 to 7.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.
- dependents: 130,286 tracked repositories and 13,189 tracked packages.
- npm.downloadsLast4Weeks, npm.downloadsSame4WeeksYearAgo, medianDownloadsRatio, peers: Nock grew 1.74× against a 4.1× median and MSW’s 4.68×.
- github.stars, bluesky.posts, peers: 13,142 stars and 3 Bluesky posts compared with MSW’s 53 posts.
- npmjs.com/package/nock?activeTab=versions: Version 13.5.6 alone had about eight times the weekly installs of 15.0.6.
Vouched for6.5
Who stands behind it being good?
Claude Opus 5.5: 6.0, likely 4.5 to 7.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.
- pistack.xyz/posts/2026-09-02-javascript-http-mocking-msw-nock-mirage-comparison: Recommends nock for pure Node backend tests
- theodo.com/blog/nock-vs-msw-i-tested-both-and-here-is-what-i-learned: Independent test; prefers MSW for most projects
- dependents.packages: 13k npm packages depend on it
- hackerNews / bluesky: 0 stories, 3 posts
GPT-6.2 Sol: 7.0, likely 5.8 to 8.1
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.
- github.com/stripe/stripe-node/blob/master/package.json: Stripe’s Node SDK lists Nock v14 as a development dependency.
- github.com/googleapis/google-auth-library-nodejs/blob/main/test/test.googleauth.ts: Google’s authentication tests use Nock for OAuth and metadata requests.
- devxtools.dev/comparisons/msw-vs-nock: Independent tests exercised the current release.
- 2025.stateofjs.com/en-US/libraries/testing: The survey tracks MSW and gives no standalone Nock rating.
Safe7.5
How safe is it to depend on?
Claude Opus 5.5: 7.5, likely 6.5 to 8.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.
- advisories.total: 0 advisories
- scorecard: 5.4; Token-Permissions 0, Security-Policy 0, Pinned-Dependencies 3
- npm dependencies: 1 runtime dependency
- github license: MIT
GPT-6.2 Sol: 7.4, likely 6.2 to 8.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.
- npm.license, npm.dependencies, advisories: MIT, one direct runtime dependency, and zero recorded advisories.
- scorecard: 5.4 overall, with token permissions at 0 and dependency pinning at 3.
- github.com/nock/nock/security: GitHub lists no published security policy or advisories.
- github.com/nock/nock/actions/runs/42130474091/attempts/1: Successful automated release run for v15.0.6.
- npm.io/package/nock: Lists v15.0.6 build provenance and four npm maintainer accounts.
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
- npm downloads, 4 weeks
- 34M +74% in a year
- GitHub stars
- 13k
- Commits, 12 months
- 32
- npm version
- 15.0.6 Nov 2026
- Versions, 12 months
- 13
- Advisories, 24 months
- 0 of 0 ever
- OpenSSF Scorecard
- 5.4 out of 10, Nov 2026
- Licence
- MIT
Read on 21 November 2026 from GitHub (nock/nock), npm (nock), 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