-
-
Notifications
You must be signed in to change notification settings - Fork 51
TypeError: Cannot read properties of undefined (reading '__reactFiber$bn58ztremuh')
while simulating event on MUI components
#45
Comments
In https://codesandbox.io/s/react17-enzyme-simulate-click-49y6pb?file=/src/components/BasicButton.js, if you render |
One way I found to make the tests work is this. Instead of simulating the event on the wrapper or on the MUI component, find the HTML element within the wrapper on which you want the event to be simulated using a CSS selector like For example, in test files, instead of doing const wrapper = mount(<BasicButton handleClick={handleClick} />);
wrapper.simulate('click'); do const wrapper = mount(<BasicButton handleClick={handleClick} />);
const button = wrapper.find('button');
button.simulate('click'); |
I narrowed the problem down to invoking I also know it's not a problem with styled-components. https://codesandbox.io/s/enzyme-adapter-react-17-wrapper-click-0brpnx |
We are also now migrating to MUI v5 and have the same issue. Any chance for this to be fixed? 🥺 |
I had the same issue with some IconButton from mui v5 to simulate('click'). And it worked well this way -> IconButton.find('button').simulate('click'); I had the same issue with the component TableSortLabel and Checkbox, where I had to search for find('span') and find('input') |
While using
React 17
, MUI 5, and latest version of@wojtekmaj/enzyme-adapter-react-17
(which is 0.6.7), when we try to simulate an event (likeclick
ormouseenter
) on MUI components likeButton
,IconButton
orTab
, we get an error likeTypeError: Cannot read property '__reactFiber$g9li6s00347' of undefined
Here is a CodeSandbox reproducing the error - https://codesandbox.io/s/react17-enzyme-simulate-click-49y6pb?file=/src/components/BasicButton.test.js
I also created a CodeSandbox to see if there is such an error while using
enzyme-adapter-react-16
withReact 16
andMUI 4
. But I didn't find such an error in it. Here is that CodeSandbox - https://codesandbox.io/s/react16-enzyme-simulate-click-67w2pj?file=/src/components/BasicButton.test.jsI think this issue is similar to the issue - #42. In that issue, return value of
_nodeToHostNode
inReactSeventeenAdapter
was some null values followed by non-null value. In this case though, all values returned from_nodeToHostNode
arenull
.The text was updated successfully, but these errors were encountered: