+0
日增长
9,752
stars
816
forks
88
watchers
1,409
prs
1,389
issues
22
releases
README
Sinon.JS
Standalone and test framework agnostic JavaScript test spies, stubs and mocks (pronounced "sigh-non", named after Sinon, the warrior).
--
Compatibility
For details on compatibility and browser support, please see COMPATIBILITY.md
Installation
via npm
$ npm install sinon
or via Sinon's browser build, shipped in the package's pkg/ directory and served by
npm based CDNs such as jsDelivr and
unpkg.
Usage
See the sinon project homepage for documentation on usage.
If you have questions that are not covered by the documentation, you can check out the sinon tag on Stack Overflow.
Goals
- No global pollution
- Easy to use
- Require minimal “integration”
- Easy to embed seamlessly with any testing framework
- Easily fake any interface
- Ship with ready-to-use fakes for timers
Contribute?
See CONTRIBUTING.md for details on how you can contribute to Sinon.JS. Artifact-first contract tests are used to protect public APIs during migration.
The lib/ directory is generated build output and is not committed to the repository; run npm run build to regenerate it locally when needed.
Backers
Thank you to all our backers! 🙏 [Become a backer]
Sponsors
Become a sponsor and get your logo on our README on GitHub with a link to your site. [Become a sponsor]
Licence
Sinon.js was released under BSD-3Top issues
#2384sandbox.restore() does not work on static members of a function or class18 comments · 2021-06-16#1651Proposal: documentation overhaul and hostnames17 comments · 2018-01-13#2003"API Specification" Style Documentation14 comments · 2019-04-02#1679How can we override reject creating a new Error Object?14 comments · 2018-02-01#1572stub.withArgs() with matchers breaks subsequent stubbing13 comments · 2017-09-26#2145Extract sandbox and fake into separate modules12 comments · 2019-10-18#1683Spy's thisValue not pointing to instance when spying constructor11 comments · 2018-02-09#440stub#returnsArg supercedes stub#returns even if returns is called later10 comments · 2014-03-24
Discussions
#2687publish release via github actions (workflow)2 comments · 2026-04-05#2655nise cannot be used standalone in pure ESM environments1 comments · 2025-04-28#2653Advice on Using Sinon to Set Future Date in Development1 comments · 2025-04-03#2614Deep partial object match with samsam?3 comments · 2024-09-12#2579Suggest improvements to how the current docs work!1 comments · 2024-01-09
Latest release
Make resetHistory work for props v4.2.2 2018-01-26Fix 1638: Make resetHistory work for props