# testdouble.js: 5.4 out of 10

Reasonable, with limits. 9th of 10 in [Mocking and test data](https://elestia.ai/opensource/mocking/index.md).

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.

## Scores

- **Overall: 5.4** (likely 4.4 to 6.5)
  - Claude Opus 5.5 (4.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): 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 many: 4.8** (likely 3.7 to 5.8)
  - Claude Opus 5.5 (4.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): 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 lot: 6.6** (likely 5.5 to 7.6)
  - Claude Opus 5.5 (6.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): 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 time: 5.9** (likely 4.5 to 7.3)
  - Claude Opus 5.5 (5.5): 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): 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 widely: 3.2** (likely 2.2 to 4.3)
  - Claude Opus 5.5 (3.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.
  - GPT-6.2 Sol (3.4): 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.
- **Vouched for: 3.9** (likely 2.7 to 5.4)
  - Claude Opus 5.5 (3.0): 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): 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.
- **Safe: 6.6** (likely 5.5 to 7.7)
  - Claude Opus 5.5 (7.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.
  - GPT-6.2 Sol (6.1): 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

- Downloads, 4 weeks: 579k
- In a year: −18%
- GitHub stars: 1.4k
- Commits, 12 months: 51
- Last npm release: Oct 2026
- Advisories, 24 months: 0
- Licence: MIT
- GitHub: https://github.com/testdouble/testdouble.js
- npm: https://www.npmjs.com/package/testdouble

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.
