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

221
Vistas
Getting error on await act() JEST. Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.Timeout

I am new to unit testing and jest, and was stuck at a scenario where the react's state are being set asynchronously after API call is resolved or rejected. I found some answers in which they've mentioned to use waitFor or await act(async()=>{}). Whenever I'm trying to await with act or even async act, I'm getting this error and the tests are failing. I've tried to replicate a similar scenario below. If these ways of handling async updates to component are not correct, then what could be the other solutions. I'm using react hooks to set the state after api resolves or rejects.

React and react-dom version : 16.8

test('new ', async () => {
  await act(() => {
    console.log('test');
  });
  expect('temp').toBe('temp');
});
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