After the update of Node.js from version 14 to version 16, we've got a lot of failed tests on bitbucket CI/CD pipelines. Locally tests pass.
Seems like the problem in timers, cause the first error message says: "FakeTimers: clearTimeout was invoked to clear a native timer instead of one created by this library.
To automatically clean-up native timers, use shouldClearNativeTimers". After that, a bunch of test fails.
After adding "--runInBand" parameter for jest it solves the issue, but it's not an ideal approach.
Will appreciate any help.
i had this same issue.
Adding
jest.runOnlyPendingTimers()
jest.useRealTimers()
in the end of my test that had the useFakeTimers() fixed it.
reference: https://testing-library.com/docs/using-fake-timers/