
Sinon.JS - Standalone test fakes, spies, stubs and mocks for …
You’ve seen the most common tasks people tackle with Sinon.JS, yet we’ve only scratched the surface. View more quick examples below, or dive into the API docs, which also provides …
API documentation - Sinon.JS
API documentation - Sinon.JS - v20.0.0 This page contains the entire Sinon.JS API documentation along with brief introductions to the concepts Sinon implements.
Stubs - Sinon.JS
When constructing the Promise, sinon uses the Promise.resolve method. You are responsible for providing a polyfill in environments which do not provide Promise.
Spies - Sinon.JS
Can be used for partial matching, Sinon only checks the provided arguments against actual arguments, so a call that received the provided arguments (in the same spots) and possibly …
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 …
Matchers - Sinon.JS
Custom matchers are created with the sinon.match factory which takes a test function and an optional message. The test function takes a value as the only argument, returns true if the …
Mocks - Sinon.JS
Typical usage: sinon.mock(jQuery).expects("ajax").atLeast(2).atMost(5); jQuery.ajax.verify(); var expectation = sinon.expectation.create([methodName]); Creates an expectation without a …
Assertions - Sinon.JS
Sinon.JS ships with a set of assertions that mirror most behavior verification methods and properties on spies and stubs. The advantage of using the assertions is that failed …
Spy call - Sinon.JS
This behaves the same as spyCall.notCalledWith(sinon.match(arg1), sinon.match(arg2), ...). spyCall.returned(value); Returns true if spied function returned the provided value on this call. …
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.