Portal.js + Fade.js snapshot testing issues
See original GitHub issueCannot use Dialog in a storybook because ReactDOM.createPortal fails and after I mock ReactDOM.createPortal, Fade.js throws errors
- This is a v1.x issue.
- I have searched the issues of this repository and believe that this is not a duplicate.
Expected Behavior
Should be able to snapshot test the Dialog
Current Behavior
I have an npm library where I am using @material-ui/core/Dialog. This library has storybooks enabled.
First issue: realized that I have to mock ReactDOM.createPortal:
ReactDom.createPortal = (node) => node;
Second issue: Then struggled for a few hours to understand what is the problem in Fade.js and got stuck at:
Error: TypeError: Cannot set property 'webkitTransition' of undefined
at:
handleExit = node => {
.....
node.style.webkitTransition = theme.transitions.create('opacity', transitionProps);
node.style.transition = theme.transitions.create('opacity', transitionProps);
I just cannot pass over this issue anymore and I don’t think I will be the only one having it.
Thanks
Issue Analytics
- State:
- Created 5 years ago
- Reactions:5
- Comments:14 (4 by maintainers)
Top Results From Across the Web
Portal.js + Fade.js snapshot testing issues - mui/material-ui
I have an npm library where I am using @material-ui/core/Dialog. This library has storybooks enabled. First issue: realized that I have to mock ......
Read more >Snapshot Testing - Jest
Snapshot tests are a very useful tool whenever you want to make sure your UI does not change unexpectedly.
Read more >Why I Never Use Shallow Rendering - Kent C. Dodds
Shallow wrapper is good to test small independent components. With proper serializer it allows to have clear and understandable snapshots. I ...
Read more >Wallaby - Immediate JavaScript test feedback in your IDE as ...
All tests that are currently failing are listed, along with errors, diffs/snapshots, error stacks and any console.log calls. The output window's hyperlinks ...
Read more >React Snapshot Testing: The Bad Parts | by Nick Gard - Medium
Do you have failing snapshot tests? No problem. Run jest --update-snapshots and now they're passing. Your colleagues may scream at you for not...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m on v4.7.1 and I was getting this error after migrating from v0 (I know, sorry.). If you’re still having trouble with this, this is what fixed it for me:
Jest tests worked fine, but storybook snapshots would error out. I put this in
storybook.test.js
file, before initStoryshots. I assume you can put this wherever you setupTests.This solutions doesn’t work for me:
This is the transition:
The modal:
I tried with this mock in the storybook.test.ts
But I got this error in the console:
I’m new to jest and I don’t know how to mock this properly. Thank you.