Chapter 14. Testing Angular applications
This chapter covers
- Using the Jasmine framework for unit testing
- Identifying the main artifacts from the Angular testing library
- Testing services, components, and the router
- Running unit tests against web browsers with the Karma test runner
- End-to-end testing with the Protractor framework
To ensure that your software has no bugs, you need to test it. Even if your application has no bugs today, it may have them tomorrow, after you modify the existing code or introduce new code. Even if you don’t change the code in a particular module, it may stop working properly as a result of changes in another module or in the runtime environment. Your application code has to be retested regularly, and that process should be automated. You should prepare test scripts and start running them as early as possible in your development cycle.
- Unit testing— Asserts that a small unit of code accepts the expected input data and returns the expected result. Unit testing is about testing isolated pieces of code, especially public interfaces.
- End-to-end testing— Asserts that the entire application works as end users expect and that all application parts properly interact with each other.