Mock API Calls
Learn how to use HttpClientTestingModule to test HTTP requests.
We'll cover the following
When we test an Angular component, we mock the data services and dependencies. We also test the service to make sure that it behaves correctly and makes the correct API calls. In most cases, we don’t want to actually call the external API, so we can make use of HttpClientTestingModule
, which we provide as a mock instead of HttpClientModule
. HttpClientTestingModule
makes it easy to make assertions about the API calls we expect and also to return mock data where required.
Get hands-on with 1200+ tech skills courses.