Unit-testing responses from HTTP calls
If you’re building an Angular application, it is very likely that you’ll work with HTTP calls inside the app at some point. For instance, you could be fetching data from a third-party API or just making APIs to your own server. In either case, it becomes slightly difficult to test applications that have HTTP calls in action. In this recipe, we’re going to learn how to create unit-tests with HTTP calls.
Getting ready
The app that we are going to work with now resides in start/apps/chapter10/ng-test-http-resp
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-http-resp
This should open the app in a new browser tab, and you should see the following:
Figure 10.14: The ng-test-http-resp app running on http://localhost...