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

Chapter 5. Test Stubs and Mocks

With the integration of Sinon.JS into our test infrastructure, we now have deeper insight into the methods and actions within our Backbone.js application. As we turn to testing the remaining application components, we will move beyond merely observing methods during tests and actually replace method behaviors.

Sinon.JS has us covered in this respect as well—the library provides solid support for functional behavior modifications. Specifically, we can leverage its powerful stub and mock abstractions to reduce Backbone.js component dependencies and cross-application side effects during testing. In this chapter, we will explore these and other Sinon.JS capabilities through the following topics:

  • Using Sinon.JS stubs to replace function behaviors and isolate Backbone.js components in tests

  • Introducing Sinon.JS mocks that spy, stub, and verify application behavior in a single abstraction

  • Writing tests for the remaining components of our Backbone.js application and deciding...