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
Problems testings material-ui components with Jest and snapshots #6834
Comments
Soulds like the issue is coming from that line: https://github.com/callemall/material-ui/blob/master/src/TextField/TextField.js#L284. |
Thanks! By the way... for some of my tests I had to mock tooltip: |
As raised by @kireerik, you can use the |
Also, we TextField has been migrated to the next branch, that should no longer be an issue. |
Hi @oliviertassinari , I think it's still an issue. Each test rerun generates new id with Math.random() here. Not possible to test components using snapshots. |
@mbaranovski Upgrade to v1-beta, we have removed the |
Thank you |
For projects which are still dependent on older versions of material-ui should jest snapshot tests be recommended for testing.... |
I noticed a bunch of classes changing in snapshots using @bishwenduk029 As a workaround you can use shallow rendering. I'm using react-test-library which doesn't support it, so unfortunately I'm still stuck. |
Changing classes in snapshots are still an issue in |
Problem description
Trying to test my app with Jest & snapshots it's failing because some attributes from some html elements rendered by Material-ui components get different values on each test.
I've asked in Stackoverflow without success.
Isn't it the best way to run some kind of tests?
Link to minimal working code that reproduces the issue
Taking for example code from material-ui docs (render a select field with multiple values):
This is my test:
However first time I run the test (no snapshots) it goes ok, but next times not (it's just an id attribute, and with some other components, an htmlFor attribute):
Versions
The text was updated successfully, but these errors were encountered: