fix(pretty-format): Render custom displayName of memoized components#8546
fix(pretty-format): Render custom displayName of memoized components#8546SimenB merged 2 commits intojestjs:masterfrom gustavovnicius:master
Conversation
Codecov Report
@@ Coverage Diff @@
## master #8546 +/- ##
=======================================
Coverage 60.57% 60.57%
=======================================
Files 269 269
Lines 11054 11054
Branches 2696 2696
=======================================
Hits 6696 6696
Misses 3772 3772
Partials 586 586
Continue to review full report at Codecov.
|
jeysal
left a comment
There was a problem hiding this comment.
Thanks, can you add a changelog entry? :)
|
@gustavovnicius Thank you. To make sure that I understand the situation:
|
SimenB
left a comment
There was a problem hiding this comment.
Missing changelog, otherwise LGTM!
@pedrottimark > Thinking back now, I believe it's better written without |
|
I added some more test cases, so I hope now it's a bit clearer |
|
Thanks! |
|
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Summary
Currently, the way
jestandenzymehandle memoized components is out of sync. This leads to some snapshot tests rendering the incorrect memoized component's displayName. e.g.: while using the latestreact-reduxversion, some connected components are memoized and they respect the customdisplayName, it can be checked here: https://github.com/reduxjs/react-redux/blob/master/src/components/connectAdvanced.js#L416.enzymehas fixed it here: https://github.com/airbnb/enzyme/pull/2137/files, notice that it checks for the type's displayName, before going to the type's type displayName.Test plan
Prior to this, when a memoized/connected
React.Nodeis passed as another component's props, the snapshot tests of that component would return<Memo(ConnectFunction)>, now they return the correct component displayName instead:<Memo(Connect(MyComponent))>You can check the wrong case here: https://github.com/gustavovnicius/enzyme-display-name-bug/blob/master/src/__snapshots__/App.test.js.snap#L6
In the snapshot, it should be
body={<Memo(Connect(Body)) />}instead ofbody={<Memo(ConnectFunction) />}