Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

92
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda