Unit-testing Angular pipes
In my opinion, pipes are the easiest thing to test in an Angular application. Why? Well, this is because they’re (supposed to be) pure functions that return the same result based on the same set of inputs. In this recipe, we’ll write some tests for a simple pipe in an Angular application.
Getting ready
The app that we are going to work with now resides in start/apps/chapter10/ng-test-pipes
inside the cloned repository:
- Open the code repository in your code editor.
- Open the terminal, navigate to the code repository directory, and run the following command to serve the project:
npm run serve ng-test-pipes
This should open the app in a new browser tab, and you should see the following:
Figure 10.18: The ng-test-pipes app running on http://localhost:4200
Now that we have the app running locally, in the next section, let’s go through the steps of the recipe.