I am writing some unit tests for my component and i am getting this cryptic error message. I found a similar question at Angular 2 unit testing - getting error Failed to load
Been chasing this for hours. Finally discovered that the problem was simply that I had imported HttpClientModule,
but not HttpClient
:
import { HttpClient, HttpClientModule } from '@angular/common/http';
All those CORS errors, and '[Script Loader]', DOMException{stack: 'Error: Failed to execute 'send' on 'XMLHttpRequest'
stuff, and it came down to just not having HttpClient!