Unit test execution

Angular CLI uses the Jasmine unit testing library to define unit tests and the Karma test runner to execute them. Best of it all, these testing tools are configured to be run out of the box. You may execute the unit tests with the following command:

$ npm test

The tests will be run by the Karma test runner in a new Chrome browser window. The main benefit of Karma is that it brings live-reloading capabilities similar to what Angular CLI achieves with WebPack when developing your application. You should observe the last message on the Terminal to be Executed 5 of 5 (5 FAILED) ERROR. This is normal, because we haven't been paying attention to the tests at all, so let's fix them all.

Karma Runner showing Jasmine Unit Test ...

Get Angular 6 for Enterprise-Ready Web Applications 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.