I have this simple function inside a service:
getReports(url: string): Observable<Report[]> {
return this.http.get<Report[]>(url);
}
My test is as follows:
it(`should call http request`, function() {
spyOn(httpClient, 'get');
const fakeUrl = 'https://reports.url/';
service.getReports(fakeUrl);
expect(httpClient.get).toHaveBeenCalledWith(fakeUrl);
const req = httpTestingController.expectOne(fakeUrl);
});
The first expectation passes (so httpClient.get
was called with the fakeUrl
, but the controller's expectOne
failed:
Expected one matching request for criteria "Match URL: https://reportss.url/", found none.
Any idea why angular's testing controller doesn't recognize my call?
Thanks!
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…