Reputation: 61894
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.
Upvotes: 2
Views: 3810
Reputation: 61894
I found the problem:
I needed to remove { provide: AuthService, useClass: MockAuthService }
, from my TestBed
's providers
list. It is no longer needed and somehow was interfering with the HttpClientTestingModule
.
Upvotes: 4