Chapter 4. Test Spies
As we begin looking at the more complicated parts of our Backbone.js application, the process of isolating dependencies and testable behaviors can become an increasingly daunting task. To provide a little help in these areas, we will introduce Sinon.JS, which is a powerful test mock, stub, and spy library, in this chapter.
Sinon.JS allows us to artificially isolate Backbone.js components and test specific behaviors without interacting with the rest of the application. We will kick off our discussion on Sinon.JS with the following topics:
Identifying some of the test limitations typically found in Backbone.js applications and testing scenarios that can benefit from test fakes
Introducing the Sinon.JS test double and assertion library
Learning how to examine application behavior with test spies
Integrating the Sinon-Chai plugin into Chai for better test assertions
Testing Backbone.js application components with test spies and other Sinon.JS utilities