In my Angular 4 application I need to create a test for a component which uses a service which internally uses the angular HttpClient.
Despite I added HttpClientTestingModule between the imports of my TestBed, I get:
TypeError: Cannot read property 'get' of undefined
whenever the component calls MyService.someMethod() (which internally uses HttpClient.get()).
I tried providing the service itself or providing a mock for it, but I'm getting the error anyway.
I found the problem:
I needed to remove
{ provide: AuthService, useClass: MockAuthService }, from myTestBed'sproviderslist. It is no longer needed and somehow was interfering with theHttpClientTestingModule.