I am using Karma to run test on my Angular 4 app. It works locally but when it runs on my host environment (Travis CI) it fails with the following informati
This is what fixed it for me:
I searched the whole project for occurrences of HttpClientModule
in all *.spec.ts
files. Turned out I had a few!
Then I replaced all occurrences of
import { HttpClientModule } from '@angular/common/http';
with
import { HttpClientTestingModule } from '@angular/common/http/testing';
And then I made sure that the entry in the imports
array of each of my test's TestBed.configureTestingModule
was changed from HttpClientModule
to HttpClientTestingModule
.
And finally I turned my Wifi off and ran the tests again. And voilà: It worketh!