Angular — A Comprehensive guide to unit-testing with Angular and Best Practices

A step by step guide to a unit testing angular project with some examples

Bhargav Bachina
Bachina Labs

--

Unit Testing ecosystem

Unit testing is as important as developing a project nowadays and it becomes an integral part of development. It actually boosts the quality of the code and confidence of developers. Unit tests are written in the Jasmine framework and executed by karma, A test runner and these are executed in the browser.

Sometimes, we write tests before we even start developing which is called TDD. We mostly follow BDD since we are using a jasmine framework.

Let’s jump in right away!! Here are the concepts that we will cover in this article

  • Features of Unit Testing
  • When can we write Unit Tests
  • Why use Jasmine
  • Why use Karma
  • Setup an Example Project with karma and jasmine
  • Testing Configuration in Angular Project
  • Key Concepts
  • Testing Component Class
  • Testing Component DOM
  • Testing pipes
  • Testing services
  • Code Coverage

--

--