
Sinon.JS - Standalone test fakes, spies, stubs and mocks for …
As before, Sinon.JS provides utilities that help test frameworks reduce the boiler-plate. Learn more about fake time. And all the rest… You’ve seen the most common tasks people tackle …
API documentation - Sinon.JS
As of Sinon 10 we stopped maintaining compatibility with legacy browsers. Instead, we focus on compatibility with evergreen browsers, Node.js LTS versions and recent Safari versions. The …
Spies - Sinon.JS
sinon.spy(object) Spies all the object’s methods. Note that it’s usually better practice to spy individual methods, particularly on objects that you don’t understand or control all the methods …
Stubs - Sinon.JS
As of Sinon version 1.8, you can use the onCall method to make a stub respond differently on consecutive calls. Note that in Sinon version 1.5 to version 1.7, multiple calls to the yields* and …
Assertions - Sinon.JS
To make sure assertions integrate nicely with your test framework, you should customize either sinon.assert.fail or sinon.assert.failException and look into sinon.assert.expose and …
Mocks - Sinon.JS
To see what mocks look like in Sinon.JS, here is one of the PubSubJS tests again, this time using a method as callback and using mocks to verify its behavior
Matchers - Sinon.JS
var stringOrNumber = sinon.match.string.or(sinon.match.number); var bookWithPages = sinon.match.instanceOf(Book).and(sinon.match.has("pages")); Custom matchers. Custom …
Releases - Sinon.JS
Their addressing schemes vary, but an example url such as https://cdn.jsdelivr.net/npm/sinon@3/pkg/sinon.js would download the latest browser bundle of …
Fakes - Sinon.JS
In Sinon, a fake is a Function that records arguments, return value, the value of this and exception thrown (if any) for all of its calls. A fake is immutable: once created, the behavior will not change.
Fake timers - Sinon.JS
Fake timers are synchronous implementations of setTimeout and friends that Sinon.JS can overwrite the global functions with to allow you to more easily test code using them. It also has …