-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Missing displayName for styled-component 4.x and enzyme-to-json #2090
Comments
enzyme does not support or encourage snapshot testing. What does |
@ljharb Hi thanks for your response. It shows same things. I guess the Could you help dig deeper for this ? If you consider it as an issue |
I believe this will be fixed in the next release of enzyme. |
Seems this should be the bug of styled-component v4, I created one fixing PR for this, styled-components/styled-components#2516 Still appreciate the enzyme team would have a double check for this issue, if nothing about enzyme, we should close this issue? Thanks ^ ^ |
v3.10.0 has now been released. Closing; happy to reopen if it's not resolved. |
@ljharb I still seem to be having a problem. I have a repo intended to demo the issue here. Just install everything and run My console output shows:
But I was expecting something more along the lines of:
Versions:
Is it possible that this is an enzyme issue? Or do you think this is on styled-component's end? |
@XxX-MLGNoob-XxX you're using enzyme's |
For latest styled-component v4 and latest enzyme version, in test cases, if we pass the Component Instance on props, when make snapshots by
enzyme-to-json
andenzyme-adapter-react-16
, thedisplayName
will missing.For the styled-component 3.x version, it works well for same enzyme version.
Only happens for the new styled-component 4.x version.
There is a relevant issue of styled-component v4, styled-components/styled-components#1985
Please help check and give some proper fixing, thanks!
Used
enzyme@3.9.0
,styled-components@4.2
,enzyme-adapter-react-16@1.12.1
,enzynme-to-json@3.3.5
, and setup"enzyme-to-json/serializer"
forsnapshotSerializers
.Here are the code sample
The simple version of SmallApp is
The
Text
component is styled component,Current behavior
Shallow or mount styled-component Component would get
<ForwardRef >
and<StyledComponent>
instead of its correct displayName.Expected behavior
Should get correct displayName in snapshots, not the
ForwardRef
, expected behavior should be like this,name={<Text ...
Your environment
Jest+Enzyme+enzyme-to-json+styled-components
Used
enzyme@3.9.0
,styled-components@4.2
,enzyme-adapter-react-16@1.12.1
,enzynme-to-json@3.3.5
, and setup"enzyme-to-json/serializer"
forsnapshotSerializers
.API
Version
Adapter
The text was updated successfully, but these errors were encountered: