10 Testing your application
This chapter covers
- The value of testing your Angular applications
- How to set up and create unit tests to test individual pieces
- Unit test strategies for directives, services, components, and pipes
- How to implement e2e tests to test the application as a whole
- Additional testing strategies
All the applications we’ve built could benefit from testing. Some developers dread writing tests, whereas others are probably wondering why I didn’t cover testing from the start. I consider testing essential, though it requires a set of new concepts and tools, which is why I waited till now.
Angular was designed to be highly testable, and projects created using the Angular CLI automatically set up basic testing scaffolding and tools for us to use. We’ll use the CLI provided tools and configuration in this chapter. Developers with experience using other tools can choose to set up something else on their own and use the ideas and concepts from this chapter with those tools.