-
-
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
[material-icons] Testing #22622
Comments
@at-webdev For internal test purposes, we leverage: However, this attribute is removed once the package is published on npm (to save bundle size and not leak test internals) with: Now, considering we frequently need this in our tests, I would be in favor of making it public with: diff --git a/packages/material-ui/src/utils/createSvgIcon.js b/packages/material-ui/src/utils/createSvgIcon.js
index 2d146ab87d..5f53ccca28 100644
--- a/packages/material-ui/src/utils/createSvgIcon.js
+++ b/packages/material-ui/src/utils/createSvgIcon.js
@@ -6,7 +6,7 @@ import SvgIcon from '../SvgIcon';
*/
export default function createSvgIcon(path, displayName) {
const Component = (props, ref) => (
- <SvgIcon data-mui-test={`${displayName}Icon`} ref={ref} {...props}>
+ <SvgIcon data-testid={`${displayName}Icon`} ref={ref} {...props}>
{path}
</SvgIcon>
); @eps1lon What do you think? |
I think icons are the one case where we could make an exception since they have reasonable user impact and no simple alternative. I just hope we don't have to argue why we ship them for icons but not component X. I'd consider the bundle size implications negligible. If you've got many icons on your page then either: compression will flatten the curve or you should look at And as a little bit of anecdotal cherry on top: facebook ships them in their SSR payload as well and twitter renders them client side. |
@oliviertassinari do you mind if I try implementing this? And would you still want to keep the |
@jaebradley in the past, we have discussed replacing as many Assuming we will keep pushing in this direction, I think that we can rename the prop in SvgIcon and update all the tests that depends on it. |
I wanted to have a look at existing |
Shouldn't people be giving their semantic icons I realize this issue is closed, but here's the language in question:
|
I am using React Testing Library, Is it possible to test in specific Material UI icon as ArrowLeft / ArrowRight instead of .MuiSvgIcon-root?
App component:
RTL Testing : Below tests are passing but it doesn't check in specific ArrowLeft or ArrowRight icon.
The text was updated successfully, but these errors were encountered: