A few more Sinon.JS test helpers

Sinon.JS provides many useful tools beyond the core test double abstractions of spies, stubs, and mocks. We have already been introduced to the sinon.test wrapper in Chapter 4, Test Spies, and will examine a few more equally convenient helpers in this chapter.


Some test helpers such as timers and servers may require the use of IE-specific Sinon.JS libraries when used with the Internet Explorer web browser. See the relevant Sinon.JS documentation sections for more details.

Fake timers

Sinon.JS can patch time and date intervals to help manage asynchronous events and callbacks in tests. Sinon.JS fake timers override native JavaScript functions, such as setTimeout and the Date class. Once faked, test code must manually ...

Get Backbone.js Testing now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.