Unit testing AngularJS components

We mentioned Karma before, the test runner for unit tests. This is the primary tool to run tests that target specific AngularJS components. We can add it to our application by creating a Node.js console project and then use npm to install the required packages.


Karma can also run generic JavaScript tests and be used as a very fast non-AngularJS test runner. More details can be found at http://karma-runner.github.io.

Installing Karma

To install Karma, we first need to create a blank Node.js console application. The name I used for the main sample application AngularJS test project was RentThatBike.Tests.Nodejs. A package.json file was created for us in this project that contains metadata information such as project ...

Get Learning AngularJS for .NET Developers now with O’Reilly online learning.

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