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

Using test spies, stubs, and mocks with SinonJS

We use unit testing to test one component of an application. That component can be a function, an object, a variable, or any outcome which is not known yet, and your unit test wants to make sure whether that particular component is working fine or not. Often, besides testing separate components, you may find testing the behavior of your methods is of the same importance. For example, how many times a method is called, what it returns, whether it has thrown any exception, what arguments it is called with, and so on. To perform these types of behavioral testing, we use test spies, stubs, and mocks.

There are few testing libraries which support test spies, stubs, and mocks. However, we found SinonJS ...

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