Open keithjgrant opened 3 years ago
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
I am also having this problem:
"react": "^17.0.2",
"@babel/preset-env": "^7.16.11",
"@babel/preset-react": "^7.16.7",
"@wojtekmaj/enzyme-adapter-react-17": "^0.6.6",
"babel-jest": "^27.5.1",
"enzyme": "^3.11.0",
"jest": "^27.5.1",
"jest-react-hooks-shallow": "^1.5.1",
"regenerator-runtime": "^0.13.9"
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?