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 ...

Get Pro AngularJS now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.