jest snapshot className issues
See original GitHub issue- I have searched the issues of this repository and believe that this is not a duplicate.
Eventually this is related to #9433 , but i’m not sure.
Expected Behavior
Snapshots should succeed when nothing was changed.
Current Behavior
Whenever introducing a new withStyles() Component or simply updating material-ui to the latest beta our jest test fails due to things like:
- className="MuiTypography-root-104 MuiTypography-body1-113"
+ className="MuiTypography-root-111 MuiTypography-body1-120"
// or
- className="MuiExpansionPanelSummary-content-169"
+ className="MuiExpansionPanelSummary-content-176"
basically the appended number changes.
Steps to Reproduce (for bugs)
Sorry I think there is no easy sandbox reproduction possible.
Context
We switched to material-ui from our existing global-css/deterministic className solution where we were able to easily snapshot components and check if they were altered. Now it seems like we have to adjust our setup, but I don’t now how.
Your Environment
Tech | Version |
---|---|
Material-UI | basically all the v1 beta branches since we started using it (~8+) |
React | 16 |
Issue Analytics
- State:
- Created 6 years ago
- Reactions:16
- Comments:38 (18 by maintainers)
Top Results From Across the Web
jest snapshot className issues #9492 - mui/material-ui
Snapshots should succeed when nothing was changed. Current Behavior. Whenever introducing a new withStyles() Component or simply updating ...
Read more >Issues with snapshot testing in Jest with material-ui
Since I've upgraded to v4 of Material UI, I'm having an issue with my classnames on snapshot testing. Meaning, the classnames are either...
Read more >Tech Poppy: Challenges with Snapshot Testing in Styled ...
We can see that the dynamic class name has changed, but what about the component's styling? There is no information about the color...
Read more >Snapshot Testing - Jest
Snapshot tests are a very useful tool whenever you want to make sure your UI does not change unexpectedly.
Read more >React Snapshot Testing: The Bad Parts | by Nick Gard - Medium
Do you have failing snapshot tests? No problem. Run jest --update-snapshots and now they're passing. Your colleagues may scream at you for not...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
For Storybook snapshots I use next thing:
.storybook/config.js
As result I got the same class names but without counter suffix
Does anything wrong?
Comments and snippets in this issue refer to
JssProvider
. The same works with material’sStylesProvider
like