Testing routing
Just like components, routes play an essential role in the way our applications deliver an efficient user experience. As such, route testing becomes paramount in ensuring a flawless performance. There are different things that we can do with routing, and we need to test for different scenarios:
- Ensure that the navigation targets the right route URL.
- Ensure that the correct parameters are made available so you can fetch the correct data for the component or filter the dataset that the component needs.
- Ensure that a particular route ends up loading the intended component.
Let's learn more about how to test all of the scenarios in the following sections.
Testing the navigation URL
The most common feature of an Angular app with routing is a component that contains some anchor elements with routerLink
directives on them. As we learned in Chapter 7, Navigate through Components with Routing, a routerLink
directive can also contain parameters...