You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The observed symptom is that the query hook always stays in the isLoading state
FAIL src/_tests/App.spec.tsx (5.103 s)
App test
✓ Loads a project without fake timers (789 ms)
✓ Loads a project with jest fake timers (legacy) (643 ms)
✕ Loads a project with jest fake timers (modern) (1021 ms)
● App test › Loads a project with jest fake timers (modern)
TestingLibraryElementError: Unable to find an element with the text: /Successfully fetched projects!/i. This could be because the text is broken up by multiple elements. In this case, you can provide a function for your text matcher to make your matcher more flexible.
Tests with jest^27.0.0
❌ fails with useFakeTimers('legacy')
❌ fails with useFakeTimers('modern') (note that useFakeTimers() defaults to 'modern' on this jest version)
FAIL src/_tests/App.spec.tsx
App test
✓ Loads a project without fake timers (769 ms)
✕ Loads a project with jest fake timers (legacy) (1027 ms)
✕ Loads a project with jest fake timers (modern) (1023 ms)
● App test › Loads a project with jest fake timers (legacy)
Unable to find an element with the text: /Successfully fetched projects!/i. This could be because the text is broken up by multiple elements. In this case, you can provide a function for your text matcher to make your matcher more flexible.
The text was updated successfully, but these errors were encountered:
Shrugsy
changed the title
🐛Requests with RTK Query do not resolve with jest v27+ useFakeTimers
🐛Requests with RTK Query do not resolve with jest useFakeTimers('modern')
Nov 23, 2021
Shrugsy
changed the title
🐛Requests with RTK Query do not resolve with jest useFakeTimers('modern')
🐛Requests with RTK Query do not resolve with various jest.useFakeTimers() configs
Nov 23, 2021
Ironically I just ran into this yesterday while trying to deal with test failures from #2409 . I did indeed end up setting all of our useFakeTimers back to 'legacy':
When using
jest.useFakeTimers()
, RTK Query requests resolve normally withjest.useFakeTimers('legacy')
, but not withjest.useFakeTimers('modern')
A repo reproducing the issue can be found here:
Tests with jest^26.6.3
useFakeTimers('legacy')
(note thatuseFakeTimers()
defaults to 'legacy' on this jest version)useFakeTimers('modern')
Test results: https://github.com/Shrugsy/rtk-query-jest-compatibility-test/runs/4305391175?check_suite_focus=true
Test file: https://github.com/Shrugsy/rtk-query-jest-compatibility-test/blob/79d6dd98a499dbc5df9f2fb631e0fa6888ed724d/src/_tests/App.spec.tsx
The observed symptom is that the query hook always stays in the
isLoading
stateTests with jest^27.0.0
useFakeTimers('legacy')
useFakeTimers('modern')
(note thatuseFakeTimers()
defaults to 'modern' on this jest version)Test results: https://github.com/Shrugsy/rtk-query-jest-compatibility-test/runs/4305392974?check_suite_focus=true
The text was updated successfully, but these errors were encountered: