-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
[ForwardRef in snapshot #14766
Comments
That is an inherent flaw with snapshot testing. If you serialize your snapshot with implementation details (or test them in general) they can fail at any time.
Depends. They do change the API of the component. They're only useless if you don't care about refs. |
@eps1lon So If I correctly understand, you changed the implementation of all MaterialUi Component and add Thanks for your answer |
Yes. It wasn't tagged as a breaking change in the release notes though. The PR properly marked itself as breaking though. Will fix that. It's hard to recommend a silver bullet to snapshot testing with 3rd party libraries. Depending on your test it's probably best to serialize them shallow with the name of the identifier i.e. if you import it as Serializing the whole component tree of 3rd party components is brittle. Imagine those components only introduce a headless component that is essentially an identity function i.e. I used snapshot testing personally but it gives you a false sense of security. It leads to throwaway test like |
I agree, I mainly use the snapshot to check I have the right components with the right props and the right style (I made a makeStyles mock to display all css properties passed to the component) in order to catch some UI regressions but I have others tests checking about the behavior. |
@VincentLanglet We have a Jest issue focusing on improving the snapshot support: #14357. Do you think that you would be able to share the solution there? |
When I upgrade to
@material-ui/core
4 and start using@material-ui/styles
, every snapshots failed.The code didn't change at all.
Is it normal ? Can we do something about it ? I think the
ForwardRef
in the snapshot add useless complexity.I even have sometime have both
WithStyle
andForwardRef
appearing in the snapshot since the update.The text was updated successfully, but these errors were encountered: