-
-
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
[test] Make it easier to test the component has the right design tokens #24761
Comments
TL;DR run automated test in a real browser for now. @aleshh Your codesandbox's behavior looks expected. JSDOM doesn't have a full CSS resolution algorithm. You can't always rely on it. Here, it could be a bug in JSDOM itself. jsdom/jsdom#2690 shares a bit more details on cascading support. We recently had a similar use case, we wanted to test that the generated CSS with emotion was using the right design token. The issue with visual regression tests is that slight changes of colors can sometimes be missed, It's not always obvious if it's using the right design token, and yet, it can be critical in making the component look great. enzyme and styled-components have snapshot testing support but it's not the same. I'm leaving it open to collect more feedback. I believe most people don't care enough to bother testing it, but I think that it's still interesting to allow collecting more feedback. |
Thanks @oliviertassinari, that makes sense. We're working on incorporating Cypress tests, which should make stuff like this way easier and more comprehensive. Or in this case, possible. |
I have added the |
- Disable failing tests as JSDOM renders backgroundColor as transparent mui/material-ui#24761 (comment) - Material UI v5 upgrade and transition to Emotion could change something
A button's color can be set to primary or secondary, and the appropriate color is applied to the button component's background color. However, when testing with testing-libraray/react, the background color is reported as
transparent
.Current Behavior 😯
Button color is reported as
transparent
.Expected Behavior 🤔
Button color should be reported as whatever the appropriate color is,
#3f51b5
for the default primary color.Steps to Reproduce 🕹
Link to codesandbox with test
Context 🔦
We're overriding the color in some of our buttons and would like to test that it's working correctly. I have also posted this as a question on Stack Overflow, with no response in over two weeks.
Your Environment 🌎
Works fine in browsers, but not in jsdom.
The text was updated successfully, but these errors were encountered: