-
Notifications
You must be signed in to change notification settings - Fork 64
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
Enzyme 3 support #63
Comments
Hi! That's interesting, I'll have a look. |
Just an FYI, I'm seeing the same issue with the more recent beta/rc versions. I was using Edit: I also found the commit in enzyme where Edit 2: Changing up this line from "ShallowTraversal" to "RSTTraversal" gets past the initial error and brings up an error with the next line: Edit 3: I was able to fix all issues by removing React v13 compatibility from the library. I understand might not be the direction you want to head in, but hopefully this info helps. I'd be happy to contribute towards fixing this one. |
Just as I told @andrewjmead and to let everyone know, I'm currently working on Enzyme 3 compatibility, it's actually not bad at all and the code is much simpler. Everything is in the |
I will close this for now and you can find more information about the progress of the next version there: #67. You can test the beta:
|
Awesome. This fixed all the issues I was seeing when using:
|
@andrewjmead nice! That would be cool if people could test it with React 16 and Enzyme 3 on a larger codebase than my unit tests. |
Hello! I try to use this update, but encounter couple issues. First:
When I have both @16.0.0-rc3. And when I use it with jest I get only shallow snapshots like this:
Is there a way to configure it? |
Hi @kirill-kruchkov! Thanks for trying out! For the first issue, that's probably not because of For the second issue, mmh are you sure you are using Enzyme 3? Can you show more details about your setup? Thanks! |
@adriantoine hi! Thanks for your response! It's like this:
And jest setup looks like:
|
Ok thanks, I will try it out on a small repo! |
@kirill-kruchkov I have just published a small test repo: https://github.com/adriantoine/enzyme-to-json-v3-testing As you can see all the snapshots are looking good so I can't reproduce your issue even though I tried different cases (function component, class component, component including other components). Can you provide more details about your use case or provide a small repo like mine where you can reproduce the issue? Thanks! |
@adriantoine thank you! Sorry I can't check it and make a repro right now, but I hope I'll have a chance to do it this evening. Will report the result here! |
@kirill-kruchkov no problem! |
@adriantoine so I see it works fine with react for web, but I try to make it work for react-native 0.47.2. Maybe this is the reason we get different results. Let me come back later with a minimum repo to reproduce. |
@kirill-kruchkov that's interesting, I'm not a |
@adriantoine I created a small repo (https://github.com/kirill-kruchkov/enzyme-to-json-v3-react-native-test) to try it but it seems like it all works fine! So I'm sorry for bothering you with this! Probably the error is somewhere else in my code. |
@adriantoine oh no, sorry again :-D Actually I reproduced it. Please check out this repo: https://github.com/kirill-kruchkov/enzyme-to-json-v3-react-native-test Turns out it saves
|
@kirill-kruchkov thank you very much, I'm looking into it! |
That's a good catch, for some reason it returns an { type: 'View',
props:
{ style:
{ flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF' } },
children:
[ { type: 'Text',
props: [Object],
children: [Array],
'$$typeof': Symbol(react.test.json) },
{ type: 'Text',
props: [Object],
children: [Array],
'$$typeof': Symbol(react.test.json) },
{ type: 'Text',
props: [Object],
children: [Array],
'$$typeof': Symbol(react.test.json) },
{ type: 'MyComponent',
props: {},
children: [Array],
'$$typeof': Symbol(react.test.json) },
{ type: undefined, // ???
props: {},
children: null,
'$$typeof': Symbol(react.test.json) } ],
'$$typeof': Symbol(react.test.json) } I'll have a look. |
@kirill-kruchkov it should be fixed in |
@adriantoine I tried it and now it's fine! Thank you a lot! Really appreciate your responsiveness! |
I still get this error on one of my projects. Ideas? |
Hey @FezVrasta, can you give more details? Can you make sure all the versions are correct?
right? |
I actually get only this part:
I have latest of enzyme, enzyme-to-json, react, react-dom, react-test-renderer, react-dev-utils, jest-enzyme, jest, enzyme-adapter-react-16 and babel-jest |
Mmh that's really strange, this import has gone in |
yes I already delete node_modules, anyway now that I look at the yarn.lock I see that both 3.0.1 and 1.5.1 are resolved. 1.5.1 seems to be required by edit, and actually, I don't seem to have |
Ok removing jest-enzyme everything works, I guess it needs an update 🙂 And here it is the existing issue: |
I'm glad to hear you solved your issue! @FezVrasta |
Yeah it seems I'm sure @blainekasten will upgrade his library very soon to work with Enzyme v3, in my case it wasn't too hard, I ended up with a much simpler code. |
Hey guys, I am indeed working on an upgrade. Hoping to cut a release soon |
ETA on release @blainekasten? No rush at all, just wondering |
Hopefully less than 15m |
Just release |
Were you guys able to make this work? I'm still having the same issue. Using jest-enzyme 4.0.0 but still having the same issue. Anyone know what I'm doing wrong? "devDependencies": { the error I get: Thank you, appreciate the help! |
|
@nickmccurdy Thank you for the response, i'm gonna try that! |
@henrique1977 you should use
|
It's working for me now! After trying a lot of different things, this is what I have in my package: so my enzyme is now "enzyme": "^2.9.1", But, I get no errors and I'm using shallow with no issues. Thank you!! |
@henrique1977 Thank you for posting the list of package versions! I resolved all my errors using that. I am also posting here the complete list of packages and config:
|
This should fix the problem: package.json
test.spec.js
|
I have the same problem and I don't know how to resolve it.
It worked before but after remove everything from node_modules it doesn't. I'm trying to run npm test for my react native app.
|
I get this error in all my test suites using
enzyme-to-json@1.5.1
,enzyme@3.0.0-alpha.1
(unmet peer dependency), andreact@16.0.0-beta.5
(unmet peer dependency).While it's clear to me that the peer dependencies are intentionally not supporting these unstable versions yet, it would be helpful to start working on support in a prerelease so projects testing React 16 and projects forced to use it because of React Native can continue to use this project until React and Enzyme are stable.
The text was updated successfully, but these errors were encountered: