Elestia Open Source Ratings
5.4

testdouble.js

Reasonable, with limits. 9th of 10 mocking and test data.

testdouble.js is a small, opinionated library for stubbing and verifying functions, objects and modules in TDD-style tests. It is still maintained, and 4.0 shipped in October 2026, but its use is shrinking fast. Most new projects get the same job done with the mocks built into Vitest or Jest, or with Sinon.

Best for: Teams doing outside-in TDD on Node who want a strict when/verify API that works with any test runner and can replace ES modules.

GitHubnpm

Scores

Overall5.4

How strongly do we recommend it for a new project today?

Claude Opus 5.5: 4.5, likely 3.5 to 5.5

It is a well-designed, still-maintained mocking library with a fine API for TDD. Its share is falling, though, and Vitest or Jest's built-in mocks and Sinon cover more cases with far more users. It is fine to keep where it runs, or for teams committed to its style, but most new projects should use their runner's mocks or Sinon.

GPT-6.2 Sol: 6.3, likely 5.2 to 7.5

Testdouble.js is a sound choice for Node.js teams that value exact call verification and built-in replacement of both module formats. Sinon.JS is the stronger general-purpose choice for teams that need call-through spies, fake timers and sandboxes. Version 4 addresses important compatibility problems, but falling adoption and the uneven maintenance record limit confidence in it as a default for new projects.

Needed by many4.8

How many developers need a tool for this job?

Claude Opus 5.5: 4.0, likely 3.0 to 5.0

Most developers who write unit tests need test doubles. But Jest and Vitest ship their own mocks, so a separate library only serves those who want a different style or use another runner. testdouble's TDD-focused, Node-only module replacement narrows that group further.

GPT-6.2 Sol: 5.5, likely 4.4 to 6.6

Mocking is a common testing need, and testdouble.js can fake functions and objects across runners in Node.js and browsers. Module replacement is specific to Node.js, and HTTP interception and test data generation require separate tools. Built-in mocks in widely used runners make the share of teams that need a standalone library harder to estimate.

Helps a lot6.6

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 when/verify API is clean, it ships types, and ES module replacement got real fixes in 2025 and 2026 (pnpm, Node 24+, memory growth, getters). By design it has no spies, partial mocks or fake timers, and import order traps users. Vitest's vi.mock and Sinon cover more cases for most people.

GPT-6.2 Sol: 7.1, likely 6.0 to 8.2

Version 4.0.0 combines exact call matching, readable failures and built-in Node module replacement, and fixes long-standing problems with getter-based exports. The small, documented API helps coding agents write basic stubs, but module replacement still depends on import order and per-test cleanup. TypeScript covers typed function doubles, while automatic ES module replacements expose exports as `any`. Limited independent performance evidence for version 4 keeps the range wide.

Holds up over time5.9

Will it still be a good choice in two years?

Claude Opus 5.5: 5.5, likely 4.0 to 7.0

There were 51 commits and 5 npm versions in the last year, including a 4.0 major in October 2026, and the Test Double consultancy owns it. But no PRs are open, nothing is published as a GitHub release, and the ecosystem is moving towards the mocks built into test runners. The project is kept up rather than growing.

GPT-6.2 Sol: 6.2, likely 4.9 to 7.5

Test Double maintains the library, with 51 commits and five npm versions in the last year. Recent releases fixed several module-loading bugs, but a user-reported memory problem took more than two years to close, and version 4 requires Node.js 22 and changes some browser-targeted imports. The recent activity is encouraging, though the long gaps and limited visibility into who can publish leave the future pace uncertain.

Used widely3.2

How many use it, and is that growing?

Claude Opus 5.5: 3.0, likely 2.0 to 4.0

It gets about 580k downloads in 4 weeks, down from 710k a year ago. That ratio of 0.82 is far below the 4.1 median. It has 3.2k dependent repos, against hundreds of thousands for Sinon and Nock. It shows no Bluesky or Hacker News attention.

  • npm downloadsLast4Weeks: 579k, down from 710k a year ago.
  • dependents repos: 3,225 repos, versus 372k for Sinon.
  • bluesky posts: 0 posts.

GPT-6.2 Sol: 3.4, likely 2.3 to 4.5

Ecosyste.ms found 3,225 dependent repositories and 1,046 dependent packages, a modest footprint beside Sinon.JS. Four-week npm installs fell about 18% to 579,154, giving a year-over-year ratio of 0.82 against the catalog median of 4.1. That points to lost ground, while automated installs and partial repository coverage leave the number of projects choosing it uncertain.

  • dependents: 3,225 repositories and 1,046 packages found.
  • npm downloadsLast4Weeks, npm downloadsSame4WeeksYearAgo, medianDownloadsRatio: 579,154 versus 710,467 installs, with a 0.82 ratio against 4.1.
  • peers: Sinon.JS has 372,404 found dependent repositories.
  • github stars, hackerNews stories, bluesky posts: 1,425 stars and zero matched Hacker News stories or Bluesky posts.
Vouched for3.9

Who stands behind it being good?

Claude Opus 5.5: 3.0, likely 2.0 to 4.5

Most independent write-ups are from 2016 and 2017 and praise its API over Sinon's. The main backer is the consultancy that maintains it. I found no current survey data, benchmarks or framework built on it.

GPT-6.2 Sol: 4.8, likely 3.4 to 6.2

UI5 CLI merged its version 4 upgrade after 75 checks passed, and the npm plugin for semantic-release also lists version 4 as a test dependency. An independent hands-on comparison supports the case for precise stubbing, though it predates version 4. Current evidence is strongest for use in a few real test suites, with little project-specific satisfaction or benchmark data.

Safe6.6

How safe is it to depend on?

Claude Opus 5.5: 7.0, likely 6.0 to 8.0

It has never had an advisory, has 4 dependencies and is MIT licensed. It is a dev dependency only. The Scorecard is weak at 3.9: there is no code review, branch protection, security policy or token permission limits.

  • advisories total: 0 advisories.
  • scorecard score: 3.9, with Code-Review, Branch-Protection and Security-Policy all at 0.
  • npm dependencies: 4 dependencies.

GPT-6.2 Sol: 6.1, likely 4.9 to 7.3

The MIT-licensed package has four direct dependencies and zero tracked OSV advisories. Its 3.9 OpenSSF Scorecard flags weak branch protection, code review and workflow token permissions, and GitHub shows no security policy. The tagged manifest includes a direct npm publish script, while publisher access and release provenance remain unclear.

Good

  • Its when/verify API reads like normal function calls, which makes stubs easy to read and write.
  • td.replaceEsm can replace native ES modules and CommonJS modules in Node, with fixes for pnpm and Node 24+ in 2026.
  • It works with any test runner (Mocha, Node's own runner, Jest, and Vitest through the testdouble-vitest wrapper).
  • It has a small dependency tree, no known advisories and an MIT licence.

Bad

  • Downloads fell about 18% in a year while the median project grew about fourfold, so few new projects pick it.
  • By design it has no spies, no partial mocks and no fake timers, so many teams need Sinon or their runner's mocks alongside it.
  • 4.0 drops Node versions before 22 and changes how getters are imitated, which can break existing tests.
  • Module replacement depends on import order, and users often hit mocks that silently never take effect.

The numbers

npm downloads, 4 weeks
579k −18% in a year
GitHub stars
1.4k
Commits, 12 months
51
npm version
4.0.0 Oct 2026
Versions, 12 months
5
Advisories, 24 months
0 of 0 ever
OpenSSF Scorecard
3.9 out of 10, Oct 2026
Licence
MIT

Read on 21 November 2026 from GitHub (testdouble/testdouble.js), npm (testdouble), OSV and the OpenSSF Scorecard.

Mocking and test data

  1. 8.5Mock Service Worker
  2. 8.1Faker
  3. 7.1Nock
  4. 6.9Mockttp
  5. 6.9Sinon.JS
  6. 6.5Fishery
  7. 5.7fetch-mock
  8. 5.6JSON Server
  9. 5.4testdouble.js
  10. 4.1Mirage JS
Compare all 10 on six scores