Testing and Test Driven Development

Let's explore why testing and test-driven development are important and why we use Jasmine for writing tests in Angular.

Why is Test-driven development important?

In the world of Angular, testing is extremely important. As we know from when we explored the Dependency Injection (DI) in Dependency Injection, Services, and HttpClient chapter, data is passed into our Components using DI. This leads to our components being isolated and separated, which is good practice. It does mean that we need to be sure that the inputs to our Components work as expected. Being able to test parts of our application in isolation is important because then we know that when all the various parts are passed into the components, they work. This is why Test-driven development (TDD) within Angular is important.

One of the reasons Angular is so popular in the enterprise software space is because Angular insists on Unit Tests being written, and well-tested software is important in the enterprise space. But before we look into how Angular makes testing so easy, we need to understand what is meant by testing and writing tests for our code. Once we understand what testing is, then we can see the ways Angular makes testing a core part of the code we write.

The first thing we need to look at is how tests are written, and for that, we need to start with Jasmine.

Get hands-on with 1200+ tech skills courses.