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
supertest failing with ECONNRESET

I'm working on a Node.js project and trying to write test cases for the app. The endpoints are working perfectly fine when I run them in Postman. But when I run the test cases, some of them, (Usually the first one in the order) fails with the error

 - Error: read ECONNRESET

I have tried debugging it, searched for a potential solution, but I'm unable to fix it. I'm working with jasmine/supertest for the first time. Maybe I'm missing something I'm unable to anticipate but I haven't been able to find out the issue. Can anybody help me out with this? Thanks a bunch in advance.

Here is my test code.

 it('Gets Users List', async() => {
     const response = await request.get('/users')
    

    expect(response.status).toBe(200);
    
})

and my Controller function

export const index = async (req:Request, res: Response) => {
try {
    const users : DataObject = await model.index()
    
    res.status(users.status);
    res.json(users.data);

  } catch (error) {
    res.status(NOT_FOUND);
    res.json(error);
  }
}

The peculiar behavior that I observed is when I add another method before this one, then this method works fine and the first one returns the same error. I assume the first call is rejected due to the fact that connection was not established yet? I'm not sure though.

Anybody familiar with this issue?

Thanks in advance.

about 4 years ago · Juan Pablo Isaza
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