Angular 5 Jasmine Error: Expected one matching request for criteria found none

后端 未结 4 1447
一生所求
一生所求 2021-01-04 05:34

I have a very simple service call and a jasmine test for it.

Service call:

myServiceCall(testId: number) : void {
    const url = `${this.url}/param         


        
4条回答
  •  日久生厌
    2021-01-04 06:22

    You've read the error wrong, let me rephrase it for you :

    Error: Expected one matching request [...], found none.

    This simply means that your URL doesn't match.

    What you can do is add a console log of your URL with

    console.log(req.request.url);
    

    Or you can simply try to match the request.

    Other solution : since you rely on environment variables, you can run this test instead :

    expect(req.request.url.endsWith("/paramX/123")).toEqual(true);
    

提交回复
热议问题