O'Reilly logo

Pro AngularJS by Adam Freeman

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

CHAPTER 25

image

Unit Testing

In this chapter, I describe the facilities that AngularJS provides for unit testing and, in particular, the services that make it easy to isolate a piece of code from the rest of the AngularJS framework to enable thorough and consistent testing. Table 25-1 summarizes this chapter.

Table 25-1. Chapter Summary

Problem

Solution

Listing

Write a basic Jasmine unit test.

Use the Jasmine describe, beforeEach, it, and expect functions.

1–4

Prepare an AngularJS test.

Use the angular.mock.module method to load the module you want to test, and use the angular.mock.inject method to resolve dependencies.

5

Mock HTTP ...

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