HttpClientTestingModule

Configures HttpClientTestingBackend as the HttpBackend used by HttpClient.

class HttpClientTestingModule { }

说明

Inject HttpTestingController to expect and flush requests in your tests.

注解

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