
About Sinon.JS
Sinon.JS is a JavaScript library for test doubles. It provides spies, stubs and mocks that work with any unit testing framework.
What it does
Spies record calls to a function, stubs replace a function with fixed behavior, and mocks let you set expectations on calls. You can check what your code called without changing the code under test. Restoring the original methods after each test keeps tests isolated from one another.
Key features
- Spies that record calls to a function
- Stubs that replace a method with fixed behavior
- Mocks that set expectations on calls
- Works with any JavaScript unit testing framework
- Installs with npm
Who it's for
JavaScript and TypeScript developers who write unit tests and need to control dependencies. Teams testing code with many external calls will find it helpful.
Pricing and good to know
Sinon.JS is free and open source. Install it with npm and import it in your test files. The documentation covers getting started, guides and core concepts, and the library is on GitHub with about 9.8k stars.
Highlights
- Spies that record calls to a function
- Stubs that replace a method with fixed behavior
- Mocks that set expectations on calls
- Works with any JavaScript unit testing framework
- Installs with npm












