This is the archived documentation for Angular v5. Please visit angular.io to see documentation for the current version of Angular.

HttpClientTestingModule

npm Package @angular/common
Module import { HttpClientTestingModule } from '@angular/common/http/testing';
Source common/http/testing/src/module.ts

Overview

      
      class HttpClientTestingModule {
}
    

Description

Configures HttpClientTestingBackend as the HttpBackend used by HttpClient.

Inject HttpTestingController to expect and flush requests in your tests.

Annotations

      
      @NgModule({
    imports: [
        HttpClientModule,
    ],
    providers: [
        HttpClientTestingBackend,
        { provide: HttpBackend, useExisting: HttpClientTestingBackend },
        { provide: HttpTestingController, useExisting: HttpClientTestingBackend },
    ]
})