RNTL accidentally triggers `jest.useFakeTimers`
See original GitHub issueDescribe the bug
I am using sinon-fake-timers together with jest, because jest’s exposes only minimal part of sinon timers and I need more advanced capabilities. The thing is that React native testing library mistakenly thinks that I am using “jest.useFakeTimers”, because of this check:
if (
typeof globalObj.setTimeout.clock !== 'undefined' &&
// $FlowIgnore[prop-missing]
typeof jest.getRealSystemTime !== 'undefined'
)
The first statement is true because I am using sinon fake timers, and the second is true because I am using jest, so it assumes that I am using jest.useFakeTimers
, and it automatically turn it on for me here:
if (fakeTimersType) {
jest.useFakeTimers(fakeTimersType);
}
This results in both custom sinon timer and jest’s fake timers being installed, and it causes issues in my tests.
Expected behavior
jest.useFakeTimers
should not be called if the user didn’t call it explicitly.
Steps to Reproduce
use jest 27 and sinon-fake-timers
Versions
npmPackages: @testing-library/react-native: ^9.0.0 => 9.0.0 react-test-renderer: ^17.0.2 => 17.0.2
Issue Analytics
- State:
- Created 2 years ago
- Comments:10 (10 by maintainers)
Top GitHub Comments
yep, i’ll do it
@mdjastrzebski jest still exposes only a subset of sinon’s options