On this page
Overview
Sinon is a standalone JavaScript testing library for spies, stubs, and mocks. It can be added to an existing test framework to observe function calls, replace dependencies, verify expectations, and fake time-dependent behavior.
Features and best fit
Based on official documentation; not hands-on tested · Content checked:
Key features
Use spies, stubs, and mocks without replacing the test framework
The README describes Sinon as standalone and test-framework agnostic, so projects can add the required test doubles to an existing runner.
Sources: [1]
Use ready-made fake timers for time-dependent code
Shipping ready-to-use timer fakes is listed as a project goal, helping tests separate time-dependent behavior from real elapsed time.
Sources: [1]
Best fit
Fits unit tests that need selective control over dependencies and calls
Sinon is useful when an existing test stack needs focused spying, stubbing, mocking, or timer control rather than a replacement testing framework.
Sources: [1]
Before adoption
Official sources
- [1]Sinon v22.1.0 README(2026-10-06)
- [2]Sinon v22.1.0 package metadata(2026-10-06)
- [3]Sinon v22.1.0 changelog(2026-10-06)
- [4]Sinon BSD-3-Clause license(2026-10-06)
Supplemental curator note
Sinon fits unit tests that need selective call observation, dependency replacement, or timer control without replacing the existing test runner. Version 22.1.0 is an ES module package, so verify module resolution in the current toolchain.
Try it in 3 steps
- 1
Get the source
git clone --depth 1 https://github.com/sinonjs/sinon.git - 2
Enter the repository
cd sinon - 3
Check the official steps
Continue with the commands in the README Installation, Quick Start, or Getting Started section.
find . -maxdepth 1 -iname 'README*' -exec sed -n '1,220p' {} \; -quit
Growth
Growth trends · Last 30 days
9,756 Stars
Trend data is still being collected.
Built with
Categories and tags
Categories
GitHub data
GitHub dataView detailed GitHub data
GitHub Topics
- javascript
- sinon
- stub
- stubs
- tdd
- test-driven-development
- test-spies
- unit-testing
- Stars
- 9,756
- Forks
- 807
- Watchers
- 94
- Open issues
- 69
- Owner type
- Organization
- Primary language
- JavaScript
- License
- BSD-3-Clause
- Repository last updated
- Oct 5, 2026
Related information
Write a related articleShare a guide or use case for this OSS in Markdown. Articles are published after administrator approval.
Explore next
- Less17,025 Stars
2 shared tag(s) · Same language
compile stylesheets with variables, mixins, and nesting into standard CSS with lessc
JavaScript - DOM Testing Library3,335 Stars
3 shared tag(s) · 1 shared category(s) · Same language
test UI with DOM queries that resemble how users find elements
JavaScript - Jest45,500 Stars
3 shared tag(s) · 1 shared category(s)
Combine assertions, mocks, watch mode, snapshots, coverage, and worker isolation in one JavaScript test runner
TypeScript - fake-indexeddb695 Stars
2 shared tag(s) · 1 shared category(s) · Same language
recreate the IndexedDB API in memory for Node.js tests
JavaScript - Playwright97,099 Stars
2 shared tag(s) · 1 shared category(s)
Drive Chromium, Firefox, and WebKit through one API and test runner for E2E, scripting, and agent browser automation
TypeScript - Storybook91,200 Stars
2 shared tag(s) · 1 shared category(s)
capture UI states once and reuse them across docs, interaction tests, and agent tooling
TypeScript
Report incorrect information
Tell us if any listing information is incorrect or outdated.