Fixed crash when calling .simulate on an emotion styled component #13
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This fixes #12 for me locally.
Without this fix, I had this error 6 times in a pretty big private codebase.
This fix doesn't result in any problems in this codebase, while it does have ~1500 enzyme unit test cases and ~250 styled components. It also makes heavy use of Material UI V5, which also uses emotion.
I made a minimum reproducible example here: https://github.com/leroydev/enzyme-adapter-react-emotion-issue and also included a way to test this fix by inlining ReactEighteenAdapter.ts with the proposed change.
After cloning this repo and running
npm i
, the old and new behavior can be compared by runningnpm run original-test
/npm run changed-test
🙂