Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

93
Views
Angular http test not finding request

I'm doing a Jasmine test mocking a HTTP request, but I'm getting the following error:

Failed: Expected one matching request for criteria "Match URL: https://myurl.net/api/v2/OperationalAreas/1/Equipments?PageNumber=1&PageSize=10&NeedPaging=TRUE&Filter=id:%3C%3E:6.", found none. Requests received are: GET https://myurl.net/api/v2/OperationalAreas/1/Equipments?PageNumber=1&PageSize=10&NeedPaging=TRUE&Filter=id:%3C%3E:6.

As you can see, the URL is identical, but it displays an error anyway.

The test is something like that:

it(
    'should do my test',
    waitForAsync(() => {
      spyOn(service, 'allTypes').and.returnValue(getAllTypesMock);

      service.getFromPage(1).subscribe((page) => {
        expect(page.items.length).toEqual(9);
      });

      service.allTypes().subscribe(() => {
        const req = httpMock.expectOne(
          `${environment.myUrl}api/v2/OperationalAreas/1/Equipments?PageNumber=1&PageSize=10&NeedPaging=TRUE&Filter=id:%3C%3E:6.`
        );
        expect(req.request.method).toBe('GET');
        req.flush(getPage1TenResponseDTO);
      });
    })
  );

Any ideas?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The solution was quite simple, actually.

I just put an extra dot (.) at the end of the url. And, as the error message itself has a period, that confused me.

So I just remove the dot and everything just worked fine.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!