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

Fake it 'til you make it


Ideally, we would run insulated, fast, and consistent tests on all parts of a Backbone.js application without any modifications. In actuality, these goals encounter hurdles for at least some of the real code paths in a Backbone.js application.

We want to test Backbone.js components in isolation, but many components have dependencies on other parts of the application. We also want the tests to run quickly, but many parts of a Backbone.js application can slow things down, including the following:

  • Network communication, such as persisting a model state to a remote backend datastore or a third party API

  • Complex DOM manipulation with Backbone.js views and templates

  • Timed events and DOM animations, especially those that deliberately wait (such as a slow jQuery fade)

Finally, many events and execution paths in a Backbone.js application are non-deterministic. For example, parallel network requests and user inputs can be received by the application in any order. To deal with these...