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

Get AngularJS Web Application Development Cookbook 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.