Angular 8 - Testing


Testing is a very important phase in the development life cycle of an application. It ensures an application quality. It needs careful planning and execution.

Unit Test

Unit testing is the easiest method to test an application. It is based on ensuring the correctness of a piece of code or a method of a class. But, it does not reflect the real environment and subsequently. It is the least option to find the bugs.

Generally, Angular 8 uses Jasmine and Karma configurations. To perform this, first you need to configure in your project, using the below command −

ng test

Now, you could see the following response −

Unit Test

Now, Chrome browser also opens and shows the test output in the “Jasmine HTML Reporter”. It looks similar to this,

HTML Reporter

End to End (E2E) Testing

Unit tests are small, simple and fast process whereas, E2E testing phase multiple components are involved and works together which cover flows in the application. To perform e2e test, type the below command −

ng e2e

You could see the below response −