Sinon.JS
Reasonable, with limits. 5th of 10 mocking and test data.
Sinon.JS is the long-standing standalone library for spies, stubs, mocks and fake timers, and it works with any test runner. It is still maintained and is a solid pick for Mocha or node:test suites. Projects on Vitest or Jest already get the same features built in, and Sinon cannot stub native ES module exports.
Best for: Teams on Mocha, node:test or another runner without built-in mocks who want mature spies, stubs and fake timers that work with any framework.
Scores
Overall6.9
How strongly do we recommend it for a new project today?
Claude Opus 5.5: 6.0, likely 5.0 to 7.0
Sinon is a mature, safe and maintained choice that does its narrow job well, and it is the best pick for spies and stubs outside Jest and Vitest. For most new projects the test runner's built-in mocks cover the same job with less setup and better ESM handling. Its growth trails the category. It is a reasonable choice with real limits, not the default.
- pkgpulse.com/guides/sinon-vs-jest-mock-vs-vi-fn-mocking-javascript-testing-2026: Recommends Sinon for Mocha and node:test only
- npm downloadsLast4Weeks: Growth ratio about 1.58, far below the 4.1 median
- raw.githubusercontent.com/sinonjs/sinon/main/CHANGES.md: Active releases through 22.1.0 in 2026
GPT-6.2 Sol: 7.8, likely 6.7 to 8.8
Sinon is a strong pick for new projects that need detailed function stubbing and clock control across runners. Active maintenance and long-running downstream integrations support that choice, while slower relative adoption and upgrade regressions lower confidence. Vitest is simpler when a team already uses it and needs module mocks, and Mock Service Worker is the better fit for HTTP interception.
- sinonjs.org/concepts/stubs: Shows the depth of Sinon’s standalone stubbing API.
- github.com/sinonjs/sinon/blob/main/CHANGES.md: Shows current release activity and fixes for upgrade regressions.
- dependents, npm download history, and medianDownloadsRatio: Large installed base with below-median download growth.
- vitest.dev/guide/mocking/modules.html: Vitest provides integrated module mocking.
- mswjs.io/docs: MSW intercepts HTTP at the network layer in browsers and Node.js.
Needed by many5.9
How many developers need a tool for this job?
Claude Opus 5.5: 5.0, likely 4.0 to 6.5
Faking functions in unit tests is a very common need. But most new JS and TS projects use Vitest or Jest, which already include spies and stubs. Sinon's own audience is mainly users of Mocha, node:test and other runners, plus older suites. The range stays wide because the share of non-Jest and non-Vitest projects is hard to pin down.
- pkgpulse.com/guides/sinon-vs-jest-mock-vs-vi-fn-mocking-javascript-testing-2026: Recommends Sinon for Mocha and node:test, and vi.fn for new Vitest projects
- main.vitest.dev/guide/migration/mocha: Vitest documents migrating from Sinon to its built-in spies
GPT-6.2 Sol: 6.7, likely 5.6 to 7.8
Spies, stubs, and fake clocks are useful across frontend and backend testing, and Sinon works with multiple runners. Many teams already get these tools from Jest, Vitest, or Cypress. The survey measures testing tool use, so the share of developers who need a separate mocking library is uncertain.
- github.com/sinonjs/sinon: Documents runner independence and browser distribution.
- 2025.stateofjs.com/en-US/libraries/testing: Shows broad Jest and Vitest use and rising Vitest adoption.
- v4.vitest.dev/guide/migration.html: Maps Sinon spies, stubs, and timers to built-in Vitest APIs.
- docs.cypress.io/app/references/bundled-libraries: Cypress provides Sinon tools through built-in commands.
Helps a lot7.4
How well does it do the job for those who need it?
Claude Opus 5.5: 6.5, likely 5.5 to 7.5
Its API for spies, stubs, mocks, matchers, sandboxes and fake timers is mature and complete, and coding agents know it well. Clear limits keep it out of the top band: it cannot stub ES module namespaces, its TypeScript types live outside the package, and its assertions are wordier than expect()-style matchers. Recent releases kept fixing correctness edge cases, for example making callId isolated per sandbox.
- github.com/sinonjs/sinon/issues/1832: Maintainers explain that native ES module exports cannot be stubbed
- raw.githubusercontent.com/sinonjs/sinon/main/CHANGES.md: 22.x fixes and Temporal support via fake-timers 15.4
- npm hasTypes: No bundled types; typings come from @types/sinon
GPT-6.2 Sol: 8.3, likely 7.1 to 9.1
Sinon 22.1 offers precise stubs, call assertions, and fake clocks, with examples for common setups and clear errors for some invalid calls. Native ES module stubbing takes extra setup, and TypeScript support comes from a separate package. The documentation gives coding agents concrete patterns to follow, while comparative speed and agent accuracy remain uncertain.
- sinonjs.org/concepts/stubs: Documents argument matching, call sequences, and stub behavior.
- sinonjs.org/concepts/sandboxes: Documents fake tracking and restoration.
- sinonjs.org/guides/how-to/stub-esm: Explains native ESM restrictions and loader workarounds.
- github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/sinon/package.json: Separate Sinon 22 declarations cover ESM and CommonJS.
- github.com/sinonjs/sinon/blob/main/CHANGES.md: Version 22.1 fixes stub return precedence and improves an invalid-argument error.
Holds up over time7.1
Will it still be a good choice in two years?
Claude Opus 5.5: 6.5, likely 5.5 to 7.5
The project is active: 117 commits and 8 npm versions in the last year, version 22.1.0 in July 2026, and a Scorecard Maintained score of 10. A few long-time volunteers do the work and no funding is visible. The ecosystem is drifting towards the mocks built into test runners. Majors arrive yearly with removals, and the 21.1 ESM rewrite shipped regressions that later releases fixed. GitHub Releases is stale (v4.2.2 from 2018), but npm and the changelog are current.
- github commitsLastYear: 117 commits in the last year
- npm versionsLastYear: 8 versions; latest 22.1.0 on 2026-07-20
- raw.githubusercontent.com/sinonjs/sinon/main/CHANGES.md: Breaking removals in v20/v21; 21.1 regressions fixed in 21.1.1 and 22.0
- sinonjs.org/guides/migration-guide: Migration guide documents the breaking changes per major
GPT-6.2 Sol: 7.6, likely 6.5 to 8.6
Sinon had 117 commits and eight npm versions in the past year. The npm record and changelog show active releases despite the stale GitHub Releases listing. Two maintainers published recent versions, LFX reports a one-day median response, and Open Collective records ongoing sponsorship. Recent patch regressions, a four-month gap since the latest npm release, and competition from built-in mocks make the two-year outlook less certain.
- github commitsLastYear, releasesLastYear, latestRelease, and pushedAt: 117 commits and a November push despite the stale Releases listing.
- npm versionsLastYear and latestPublishedAt: Eight versions in a year, most recently in July 2026.
- github.com/sinonjs/sinon/blob/main/CHANGES.md: Credits two recent releasers and documents compatibility changes and fixes.
- insights.linuxfoundation.org/project/sinonjs-sinon: Reports six active maintainers with merge rights and a one-day median response.
- opencollective.com/sinon: Shows recurring sponsorship and a modest budget.
- github.com/sinonjs/sinon/issues/2678: A user reported broken Buffer matching in 21.0.2, fixed in 21.0.3.
Used widely7.1
How many use it, and is that growing?
Claude Opus 5.5: 7.0, likely 6.0 to 8.0
Use is very large: about 55M downloads in four weeks and 372k dependent repos, the most in the category. Growth is weak, though. Its download ratio of about 1.58 is far below the 4.1 median, so it is losing share while MSW and Faker climb. Much of its use comes from old Mocha codebases rather than new choices.
- npm downloadsLast4Weeks: 54.9M, against 34.7M a year ago (ratio about 1.58, below the 4.1 median)
- dependents repos: 372,404 repos and 70,717 packages, the most of any peer
- bluesky posts: 0 posts, so little current buzz
GPT-6.2 Sol: 7.2, likely 6.0 to 8.3
The indexed 372,404 repositories and 70,717 npm packages show substantial use, with the highest repository count among the listed peers. Four-week downloads rose from 34.7 million to 54.9 million, but the 1.58× ratio trails the catalog’s 4.1× median and MSW’s 4.68×. That signals a loss of relative ground, while automated installs and packages that pull in Sinon make fresh direct adoption hard to estimate.
- dependents and peers dependentRepos: 372,404 indexed repositories, versus 130,286 for Nock and 11,851 for MSW.
- npm downloadsLast4Weeks, downloadsSame4WeeksYearAgo, and medianDownloadsRatio: Sinon downloads grew 58% year over year, below the catalog benchmark.
- github stars, bluesky posts, and peers: 9,751 stars and zero counted Bluesky posts, versus MSW’s 18,356 and 53.
- github.com/m-radzikowski/aws-sdk-client-mock/blob/main/packages/aws-sdk-client-mock/package.json: Shows downstream installs through an AWS SDK testing package.
- docs.cypress.io/app/references/bundled-libraries: Bundled use gives developers access without a separate Sinon install.
Vouched for6.9
Who stands behind it being good?
Claude Opus 5.5: 6.0, likely 5.0 to 7.5
Many large projects have relied on Sinon for years, and its fake-timers package is built into Vitest and Jest, which is strong indirect endorsement. Current independent praise is thin: there are no Hacker News or Bluesky mentions, and the State of JS results we found do not single it out. Comparison write-ups recommend it only for setups without Jest or Vitest.
- main.vitest.dev/guide/migration/mocha: Vitest uses @sinonjs/fake-timers internally
- 2025.stateofjs.com/en-US/libraries/testing: The survey's testing section does not highlight Sinon
- hackerNews stories: No HN stories matched
GPT-6.2 Sol: 7.8, likely 6.6 to 8.8
Cypress builds its spies, stubs, and clock commands on Sinon, and Microsoft lists Sinon in the VS Code test stack. The AWS SDK client mock also relies on it, and Jest and Vitest use its separate fake-timers package. Several of these integrations use older releases or only the timer component, so they give limited evidence about satisfaction with Sinon 22.1.
- docs.cypress.io/app/references/bundled-libraries: Cypress builds core test commands on Sinon.
- github.com/microsoft/vscode/blob/main/package.json: VS Code lists Sinon 12 and its types as development dependencies.
- github.com/m-radzikowski/aws-sdk-client-mock/blob/main/packages/aws-sdk-client-mock/package.json: The AWS SDK client mock depends on Sinon 18.
- jestjs.io/docs/jest-object: Jest uses the separate @sinonjs/fake-timers package.
- v4.vitest.dev/guide/migration.html: Vitest uses the same fake-timers package.
Safe7.7
How safe is it to depend on?
Claude Opus 5.5: 8.0, likely 7.0 to 9.0
There are no advisories, only 4 dependencies (all inside the sinonjs organisation), and the permissive BSD-3-Clause licence. The Scorecard is 7.5 overall, with weak checks for Security-Policy, CII-Best-Practices and Fuzzing, and releases are not signed. It is a dev dependency, which lowers the impact of any problem.
- advisories total: 0 advisories
- scorecard score: 7.5; Security-Policy 0, CII 0, Fuzzing 0
- npm dependencies: 4 dependencies; BSD-3-Clause licence
GPT-6.2 Sol: 7.4, likely 6.0 to 8.6
Sinon has four direct dependencies, a permissive BSD-3-Clause license, and zero direct advisories in the OSV snapshot. The current release uses a patched version of diff after an earlier dependency report. The 7.5 Scorecard shows strong workflow permissions but flags missing security policy and fuzzing, and the project documents a manual npm publish step. Release attestations remain unverified, and LFX flags two serious findings whose package scope is unclear.
- npm dependencies, npm license, and advisories total: Four direct dependencies, BSD-3-Clause, and zero direct OSV advisories.
- scorecard score and checks: 7.5 overall, with strong token permissions and gaps in security policy and fuzzing.
- github.com/sinonjs/sinon/issues/2674: Tracks a dependency advisory and confirms the patched diff version was adopted.
- github.com/sinonjs/sinon/blob/v22.1.0/package.json: The stable release declares diff 9.
- github.com/sinonjs/sinon/blob/main/RELEASE.md: Documents manual npm publishing followed by a push of Git tags.
- insights.linuxfoundation.org/project/sinonjs-sinon: Flags two serious findings at the project level without identifying packages in the public summary.
Good
- It works with any test runner, so the same stubs, spies and sandboxes run under Mocha, node:test, Jasmine or Karma.
- Its matchers (sinon.match) are rich and composable, and sandboxes restore many stubs in one call.
- Its fake timers (@sinonjs/fake-timers) are so solid that Vitest and Jest use them internally, and they now cover the Temporal API.
- It pulls in only 4 dependencies, has no known advisories and uses the permissive BSD-3-Clause licence.
Bad
- It cannot stub named exports of native ES modules. You need dependency injection or a loader-based tool such as testdouble or esmock.
- It ships no TypeScript types of its own, so typings come from the separately maintained @types/sinon.
- Vitest and Jest include vi.fn and jest.fn, so many new projects never need it, and its downloads are growing more slowly than the category's.
- Majors land every year with removals such as fakeServer and fake XHR in v20, and the 21.1 ESM migration brought regressions that later patches had to fix.
The numbers
- npm downloads, 4 weeks
- 55M +58% in a year
- GitHub stars
- 9.8k
- Commits, 12 months
- 117
- npm version
- 22.1.0 Jul 2026
- Versions, 12 months
- 8
- Advisories, 24 months
- 0 of 0 ever
- OpenSSF Scorecard
- 7.5 out of 10, Nov 2026
- Licence
- BSD-3-Clause
Read on 21 November 2026 from GitHub (sinonjs/sinon), npm (sinon), 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