O'Reilly logo

Write Modern Web Apps with the MEAN Stack: Mongo, Express, AngularJS, and Node.js by Jeff Dickey

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 12. Testing Angular.js

In the previous two chapters, you wrote an end-to-end test with Protractor and tests for the Node server. Now you’ll look at writing tests on the client side for Angular.

Using Karma

Much like end-to-end tests have Protractor as the runner, Angular tests make use of Karma. Karma is a test runner designed for unit testing. It can also run in multiple browsers, including Chrome, Firefox, and PhantomJS. Built by the Angular team like Protractor, Karma has a similar configuration setup and ways to run it.

The biggest difference with Karma is that you’re usually not working with the DOM, so the UI isn’t important. In fact, you won’t even be using your layout file. For this reason, most developers run Karma under a ...

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