Book Image

Backbone.js Testing

By : Ryan Glenn Roemer
Book Image

Backbone.js Testing

By: Ryan Glenn Roemer

Overview of this book

Table of Contents (13 chapters)
Backbone.js Testing
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

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.

Tip

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 advance the time through the API tick(ms) function that simulates the passage of time for any time-based asynchronous event in the program. See http://sinonjs.org/docs/#clock for the full API reference.

Fake timers are quite useful for testing Backbone...