O'Reilly logo

Backbone.js Patterns and Best Practices by Swarnendu De

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Testing with QUnit

QUnit (http://qunitjs.com), a lightweight unit testing framework maintained by the jQuery team, which is quite easy to work with compared to other frameworks. Discussing QUnit in complete detail is beyond the scope of this book, but we will learn about the simple features of it and explore how we can use it with our Backbone components.

Assertions are the most essential elements of any unit test framework. You need to compare your actual implementation values to the results that the test produces. Assertions are the methods that serve this comparison functionality. QUnit has only eight assertions; we are going to use some of them in the next section. Let's discuss a few of them here:

  • ok (state, message): This passes if the first ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required