[test] Modal snapshot test fail "TypeError: parentInstance.children.indexOf is not a function"
See original GitHub issue- I have searched the issues of this repository and believe that this is not a duplicate.
Expected Behavior
I expect the tests to run without a problem.
Current Behavior
I get an error:
TypeError: parentInstance.children.indexOf is not a function
I think this is due to portals not working properly in combination with jest snapshots.
Steps to Reproduce (for bugs)
import React from 'react';
import { storiesOf } from '@storybook/react';
import AlertDialog from './AlertDialog';
storiesOf('AlertDialog', module)
.add('basic', () => <AlertDialog bodyKey="test" onClick={() => {}} titleKey="test" open />);
Where <AlertDialog />
is a boring wrapper around <Dialog />
.
I’m sorry for not including a code snippet. I don’t know how to set up the tests to illustrate the issue, but I tried my best to provide as much relevant information as possible.
Context
I’m using storybooks with storysnaps (jest snapshots), and our tests are failing. I’m pretty sure it has something to do with https://github.com/airbnb/enzyme/issues/1150 and potentially https://github.com/reactjs/react-modal/issues/553 could benefit from a solution as well.
Your Environment
Tech | Version |
---|---|
Material-UI | 1.0.0-beta.21 |
React | 16.0.0 |
browser | N/A |
Additional
I have a feeling this is something that could be caught in storyshots but I’m not experienced enough with the material at hand. Any pointers, or better yet solutions would be greatly appreciated.
I’m not against fixing it and contributing either (if I get the right pointers to help me out).
Issue Analytics
- State:
- Created 6 years ago
- Reactions:7
- Comments:21 (8 by maintainers)
Top GitHub Comments
Came across the same issue… Environment
Component
Test
Error message ● Error component › should render
I still have this issue using material-ui and react-test-renderer 16.13.0.
Is the solution here to use
createMount
frommaterial-ui/test-utils
?I would like to continue to use
react-test-renderer
.