Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

94
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda