Encountered an error while attempting to test my service, despite following the steps outlined in this tutorial
NullInjectorError: No provider for HttpTestingController!
error properties: Object({ ngTempTokenPath: null, ngTokenPath: [ 'HttpTestingController', 'HttpTestingController' ] })
at <Jasmine>
at...
weatherDto
export class WeatherDto {
name: String;
weather: String;
weatherIcon: String;
temp: Number;
pressure: Number;
minTemp: Number;
maxTemp: Number;
}
weather service
import { Injectable } from '@angular/core';
import { environment } from 'src/environments/environment';
import { HttpClient, HttpHeaders } from '@angular/common/http';
...
@Injectable({
providedIn: 'root'
})
export class WeatherService {
...
}
test
import { TestBed } from '@angular/core/testing';
...
describe('WeatherService', () => {
let service: WeatherService;
let httpMock: HttpTestingController;
beforeEach(() => {
...
});
it('be able to retrieve weather from the API via GET', () => {
...
});
})
Even with a successful response from the Spring Boot API, encountering difficulties testing the service. Strange occurrences with Chrome version 71.0.3578 (Linux 0.0.0) leading to unexpected failures in the WeatherComponent creation. Struggling to identify the root cause of these issues!