How to unit test your Angular 9 application using karma testing framework.

ZeroesAndOnes
7 min readJun 8, 2020

In this article I will offer the best tips and techniques for unit and integration testing your Angular 9 applications.

1 — Create a new Angular 9 application

First let’s create a simple Angular 9 application which we will use for the demonstration purposes of how to implement unit testing.

If you want a detailed step-by-step tutorial showing you how to create a new Angular 9 application, I have written an article that details the process. You can see it here:

Run the following command in you VScode terminal:

ng new UnitTestExample

and follow the prompts on the screen. Creating the application will take few minutes to download all of the necessary dependencies. Once the application is completed successfully you will get a prompt in the terminal indicating so.

Please not that the Angular CLI downloads and installs everything you need to test your application with the Jasmine test framework (link). This makes it much more easier on you as a developer. Right off the bat you do not need to perform any configuration.

--

--