Jest Timers not working while running in CircleCI Android App Build

15 Views Asked by At

We have an Ionic Capacitor app using React (@ionic/react: "6.3.5", react: "17.0.2", react-scripts: "4.0.2") and build apps using a CircleCI pipeline with this Docker image for Android: cimg/android:2023.03-browsers.

All of our Jest tests are passing when I run them locally on my computer but several are failing when they are run in our Android Circle CI pipeline, but not our iOS one. The error I get for the failures is:

thrown: "Exceeded timeout of 5000 ms for a test.
    Use jest.setTimeout(newTimeout) to increase the timeout value, if this is a long-running test."

I have already found several Stack Overflow questions that say that error is resolved by just setting the timeout to a longer time. Those did not work for me.

I did discover however that if I set jest.useFakeTimers() I get the exact same test failures when I run it locally. So I am wondering if its something about the CircleCI pipeline using fake timers. Adding a jest.useRealTimers() also does not fix it.

Is there a different way I can configure the CircleCI pipeline to run the tests properly?

0

There are 0 best solutions below