-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Cannot read property createContext of undefined with Jest #2339
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
+1, having the same issue here |
This is not the first time that having a sub-directory named |
Hey any updates on this? |
should we just rename it to |
@TrueWill would you like to contribute this? |
Any updates here? If someone wants to contribute the change, I’d be happy to look at it and merge it |
Sorry - I don't even have time to update my own OS projects right now. :/ |
I am going to try to fix this on Friday, we have an OSS contribution day at work. |
@TrueWill @TkDodo I tried creating a reproduction in CodeSandbox but I can't reproduce it there https://codesandbox.io/s/react-query-2339-xgupz?file=/src/TestComponent.test.js I'll try to create a reproduction locally Update: reproduction repo https://github.com/EddyVinck/react-query-2339 Running into some issues with |
PR open 🚀 |
will be available in v4. |
Describe the bug
Getting
on
import { useQuery } from 'react-query'
when running tests with Jest.To Reproduce
Steps to reproduce the behavior:
We saw this when using a jest.config.js with the line
moduleDirectories: ['node_modules', './'],
react-query v3.16.0
Expected behavior
Every other library works fine with Jest.
Desktop (please complete the following information):
Additional context
A coworker figured out a fix based on blitz-js/blitz#1323 - changing the Jest config to
moduleDirectories: ['node_modules', '<rootDir>'],
. But this is the only library that's affected by it. According to the linked issue, this is caused by react-query havingrequire("react")
inside a folder named react.The text was updated successfully, but these errors were encountered: