1×
Become a member
to unlock all features
Autoplay

    Mock HTTP Requests made with Angular’s HttpClient in Unit Tests

    angularAngular
    4 - 6

    In a proper unit test we want to isolate external dependencies as much as possible to guarantee a reliable test outcome. Http calls represent such external dependencies. Therefore, when testing our Angular components or services that rely on data retrieved via Http, we need to make sure to mock such calls and instead provide some fake data during the test execution. In this lesson we about the new HttpClientTestingModule and HttpTestingController that has been added in Angular v4.3.1 to make our life easier.