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

216
Views
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
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!