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
I've just installed jest-react-hooks-shallow and added enableHooks(jest, { dontMockByDefault: true }) in my test setup script, and I'm seeing countless test failures in tests that use mount(), multiple errors several similar to this:
Warning: React has detected a change in the order of Hooks called by Formik. This will lead to bugs and errors if not fixed. For more information, read the Rules of Hooks: https://fb.me/rules-of-hooks
Previous render Next render
------------------------------------------------------
1. useRef useRef
2. useRef useRef
3. useRef useRef
4. useRef useRef
5. useRef useRef
6. useRef useRef
7. useReducer useEffect
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
I'm using react-scripts (create-react-app), so I had to add enableHooks in the setupTests.js script they provide (adding setupFilesAfterEnv directly to my package.json caused an error telling me to add to this file instead, as react-scripts loads their setup file automatically).
Am I missing something? Or is there a problem with dontMockByDefault and react-scripts?
The text was updated successfully, but these errors were encountered:
Also, thank you for this library :). I've really missed shallow rendering since we've started using hooks more regularly, and I really hope I can get it working
dontMockByDefault seems to not be mocking the hooks for shallow renders as expected, but it's still causing problems with mount. I have found that if I wrap the tests with withoutHooks it works as expected, but my understanding is that this shouldn't be necessary if dontMockByDefault is set to true.
I've just installed jest-react-hooks-shallow and added
enableHooks(jest, { dontMockByDefault: true })
in my test setup script, and I'm seeing countless test failures in tests that usemount()
, multiple errors several similar to this:I'm using react-scripts (create-react-app), so I had to add
enableHooks
in thesetupTests.js
script they provide (addingsetupFilesAfterEnv
directly to my package.json caused an error telling me to add to this file instead, as react-scripts loads their setup file automatically).Am I missing something? Or is there a problem with
dontMockByDefault
and react-scripts?The text was updated successfully, but these errors were encountered: