-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
TypeError: Cannot read property 'current' of undefined #2004
Comments
I have the same issue with the same packages |
Same issue here! |
Is this to do with being a stateless component that you're testing? We have the same issue, but its only happening on components that are not extending from |
Yes, it is the stateless component. |
Update your React to |
I updated both react & react Dom 16.8.0 along with enzyme-react-adapter version 1.9.1, and I get the error:
|
@MahaZaid what about My versions:
|
I added react-test-renderer but I am still getting the same error
|
@MahaZaid how you are running tests? It seems like Jest don't know that test should be run in JSDOM environment. Please try to add |
I am using mocha, enzyme, and @babel/register for running structural tests |
I'm having a similar issue when using jest. All of my test are now failing. I'm not sure what was updated that caused this, but it started happening this morning. I'm getting a mix of errors, "enzyme": "^3.8.0", I don't have enzyme-adapter-utils in my pakcage.json file. |
@c316 updating React to |
@benedyktdryl Updating React isn't always an option. |
@benedyktdryl thanks, that update, plus adding the |
To resolve that error I had to install the |
I understand, but in most cases - this particular issue can be solved by syncing React version as in earlier I simply can't spot |
I have the exactly same error as @MahaZaid
Of course downgrading to react 16.7.0 works fine. |
For those that can not upgrade react, we solved the issue changing the react adapter form |
I've been fighting with the Before (broken) import browserEnv from 'browser-env';
import Enzyme from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
Enzyme.configure({ adapter: new Adapter() });
browserEnv(); After (working) const browserEnv = require('browser-env');
browserEnv();
const { configure } = require('enzyme');
const Adapter = require('enzyme-adapter-react-16');
configure({ adapter: new Adapter() }); My guess is the adapter is trying to access |
Hey We found a solution, which was:
|
@Zveroboev every react package must always have an identical minor; so the fact that you're using If you've done that, and you're still having an issue, I'll reopen - if anyone else is having an issue, please file a separate one - and make sure all react packages have identical minor versions. |
This just reoccurred now after updating react-dom, I had to update all other react dependencies to 16.9 (in my case) |
@tolumide-ng all react packages (including react-dom and react-test-renderer) must always have an identical minor version. |
Keeping the |
not working for me:
API
Version
|
@ghasemikasra39 your react, react-dom, and react-test-renderer must be on the same minor version - your react-dom is on 16.10. |
See solution at testing-library/react-hooks-testing-library#151 (comment); this is likely due to version mismatch as mentioned above. Instead of trying to upgrade react, you could also simply downgrade react-test-renderer so that they're all on the same version (in this case 16.6.3). |
Is there a workaround for those of us who cannot simply up/downgrade npm modules? I'm using them in a react native app, so the react-dom isn't an issue. |
@mjstelly react-dom is still an issue there, unless there's a react-native enzyme adapter i'm unaware of. |
You are correct @ljharb. I just overlooked it in the enormously long list of packages. ;-) |
I have the following |
All three need to match the same minor version, so presumably the easiest is to upgrade react-dom to 16.6, and downgrade rect-test-renderer to 16.6. |
I updated those packages in my local branch and the original So, since this issue is closed, should I create a different issue to address my original problem? |
If your original problem still occurs when the deps are fixed, yes please :-) |
I solved this by
Note like WTF, i was using jsdom 6.0.1 and it had the above error: i changed it to 6.0.0 worked mean the error was gone and i my brake point after Mount got hit! |
This happened after "enzyme-adapter-utils" was updated to version 1.10.0.
As well, I have
import 'jsdom-global/register';
at the beginning of the test file.API
Version
Adapter
The text was updated successfully, but these errors were encountered: