Unit testing our application

The angular-seed project comes with Unit testing baked in. In the terminal window, run the following command:

npm test 

This will run the default tests and show the output in the terminal window. We will notice that the tests fail. The reason being our tests are looking for the myCtrl1 or myCtrl2 function within our controller, but it isn't there.

Let's open up our test/unit/controllersSpec.js file and remove those default tests. Save the file and immediately you will notice that our tests pass.

Let's write our Unit test to test the web services we wrote.

Get AngularJS Web Application Development Blueprints now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.