O'Reilly logo

AngularJS Testing Cookbook by Simon Bailey

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

Mocking injected instances using spies

In the Mocking injected instances using an object recipe in this chapter, we stated that if the module you're testing has other module dependencies, you need to maintain isolation, as well as ensure that they are resolved appropriately. Jasmine provides functions called spies (http://jasmine.github.io/2.0/introduction.html#section-Spies). Spies are used by tests to imitate to be functions or objects and offer the ability to then track calls made to the spy, plus query arguments that may also have been provided. They have their own set of special matchers that enhance testing against expectations. This additional set of features augment our testing capabilities offering a greater range of expectations than ...

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