Backbone.js Testing

Backbone.js is an open source JavaScript framework that aims to structure web applications by providing models with key-value binding and custom events, collections with a rich API of functions, views with declarative event handling and a RESTful JSON interface. The book “Backbone.js Testing” offers a nice overview on how to test JavaScript code in general, and more specifically Backbone.js applications.

Backbone.js Testing

In his introduction, the author writes, ” This book is for JavaScript developers who are looking to create and implement test support for Backbone.js web applications. You should be comfortable with the JavaScript programming language and familiar with Backbone.js.” I think that it will be however a mistake to limit the audience of this book only to Backbone.js practitioners. The book discusses extensively about how to create and maintain tests and a test infrastructure for JavaScript code. It contains a good introduction to many open source testing tools for JavaScript. It provides also the basics concepts on how to write tests and, more important, how to write testable code. I will therefore recommend this book to every JavaScript developer and tester.

Reference: Backbone.js Testing, Ryan Roemer, Packt Publishing, ISBN 978-1-78216-524-8

Web site: http://backbone-testing.com/

Quotes

JavaScript web applications are already notoriously difficult to verify and test: asynchronous DOM events and data requests are subject to timing issues and spurious failures, display behavior is difficult to isolate from application logic, and test suites depend on/interact with a specific browser. Frontend frameworks such as Backbone.js add another level of complexity with additional interfaces that need to be isolated and tested, large numbers of various small components interacting concurrently, and event logic propagating throughout application layers. Moreover, the implementation agnostic paradigm of Backbone.js produces wildly varying application code bases, making test guidelines and heuristics something of a moving target.

Application development is a journey guaranteed to include inexplicable errors, sudden application crashes, and complex test failures. When these pitfalls happen, it is important to have some directions on how to debug the problems and move things forward. A common scenario during software development is when application changes break one or more existing unit tests. In this case, a good practice is to run the test suite one test at a time, fix the test, and then move on to the rest.