This was a previously #9492 however it does not actually provide a fix for the core problem which is that in testing environments we should be able to mount(<Component>) that are created from withStyles() and have snapshots be reliable without wrapping them.
Expected Behavior 🤔
Snapshots should create reliable labels for withStyles() used by both custom and defaut material-ui components like in the red portion of this Snapshot:

Current Behavior 😯
One can modify a custom component to have
withStyles(Styles, { generateClassName: (rule, styleSheet) => (`${styleSheet.options.classNamePrefix}-${rule.key}`)
})
However, this only modifies overwritten styles in material UI, default ones are actually not modified at all:

## Steps to Reproduce 🕹
This can't be easily reproduced in a sandbox environment.
Link:
- Make a withStyles() that uses MUI components as well
- Install a testing framework like jest
- Run snapshots
- Add a new test, and you will see how the snapshots will fail on prior ones because the
ruleCounter increases.
Context 🔦
I would like to be able to mount() and call Jest's native .toMatchSnapshot() without worrying about the ruleCounter adding random numbers. It is not appropriate to wrap every object in a as stated in the docs of https://material-ui.com/customization/css-in-js/#creategenerateclassname-options-class-name-generator because tests should mirror their native implementation.
Your Environment 🌎
Ma
| Tech |
Version |
| Material-UI |
v3.9.1 |
| React |
16.5.2 |
| Browser |
|
| TypeScript |
|
| etc. |
|
This was a previously #9492 however it does not actually provide a fix for the core problem which is that in testing environments we should be able to
mount(<Component>)that are created fromwithStyles()and have snapshots be reliable without wrapping them.Expected Behavior 🤔
Snapshots should create reliable labels for withStyles() used by both custom and defaut material-ui components like in the red portion of this Snapshot:

Current Behavior 😯
One can modify a custom component to have
However, this only modifies overwritten styles in material UI, default ones are actually not modified at all:

## Steps to Reproduce 🕹 This can't be easily reproduced in a sandbox environment. Link:ruleCounterincreases.Context 🔦
I would like to be able to mount() and call Jest's native
.toMatchSnapshot()without worrying about the ruleCounter adding random numbers. It is not appropriate to wrap every object in a as stated in the docs of https://material-ui.com/customization/css-in-js/#creategenerateclassname-options-class-name-generator because tests should mirror their native implementation.Your Environment 🌎
Ma