Karma is making me confused again.. This is how the test looks like, I call httpMock.verify()
in afterEach(..)
. The error message is Error: Timeout - Async function did not complete within 5000ms
.
it('search user service should send GET request and return data', (done) => {
let filter = '?filter=hans'
inject([HttpTestingController, SearchUserService],
(httpMock: HttpTestingController, service: SearchUserService) => {
service.findUser(filter).subscribe(data => {
expect(data).toBeTruthy();
done();
});
const req = httpMock.expectOne(`http://localhost:8080/api/rest/frontend/user${filter}`)
expect(req.request.method).toEqual('GET')
req.flush({
data:
{
..
}
});
})
});
The findUser()
function returns an Observable<any>
. What is wrong here?
Aucun commentaire:
Enregistrer un commentaire