1 Introduction to testing Angular applications

This chapter covers

  • Understanding Angular testing
  • Getting a first look at TypeScript
  • Understanding the basics of unit and end-to-end tests
  • Introducing Jasmine, Karma, and Protractor

Poorly written code, buggy functionality, and bad refactoring practices can lead to unreliable applications. Writing good tests will help detect these types of problems and prevent them from negatively affecting your application. It’s vital that you thoroughly test your application if you want to make it sustainable and supportable for years to come. A core purpose of writing tests is to help guard against breaking application functionality when you have to add new features or make bug fixes later on.

If you’ve developed an Angular application, you may know that Angular is a great framework for building testable web and mobile web applications. One of the goals in writing Angular was to make it a testable framework, and it shows.

Although testing Angular applications is of utmost importance, figuring out how to do that has been challenging until now. You may have been able to find a blog post or two, perhaps a video, but generally materials have been lacking to help guide you through all the different aspects of testing in one place. Well, you’re in luck! In your hands (or on your screen), you hold the key to getting started with testing Angular applications.

1.1 Angular testing overview

1.2 Getting friendly with TypeScript

1.3 A closer look at test types

1.3.1 Unit tests

1.3.2 E2E tests

1.3.3 Unit tests vs. E2E tests