Writing basic unit tests
Unit tests should be the foundation of your test suite. Compared to end-to-end tests, they are generally faster, easier to write, easier to maintain, require less overhead while setting up, more readily scale with the application, and provide a more obvious path to the problem area of the application when you debug a failed test run.
There is a surplus of extremely simplistic testing examples available online and rarely do they present a component or test case that is applicable in a real-world application. Instead, this recipe will jump directly to an understandable application component and show you how to write a full set of tests for it.
Getting ready
For this recipe, it is assumed that you have correctly configured your local setup so that Grunt will be able to find your test file(s) and run them on the Karma test runner.
Suppose that you have the following controller within your application:
(app.js) angular.module('myApp') .controller('HandleCtrl', function($scope...