[material-icons] Testing
See original GitHub issueI am using React Testing Library, Is it possible to test in specific Material UI icon as ArrowLeft / ArrowRight instead of .MuiSvgIcon-root?
App component:
return {open ? <ArrowLeft/> :<ArrowRight/>}
RTL Testing : Below tests are passing but it doesn’t check in specific ArrowLeft or ArrowRight icon.
describes("MockTest",()=>{
it("renders Left arrow",()=>{
const {container} = renders(<App open={true}/>);
expect(container.querySelector(".MuiSvgIcon-root").toBeTruthy();
});
it("renders Right arrow",()=>{
const {container} = renders(<App open={false}/>);
expect(container.querySelector(".MuiSvgIcon-root").toBeTruthy();
});
});
- I have searched the issues of this repository and believe that this is not a duplicate.
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (5 by maintainers)
Top Results From Across the Web
[material-icons] Testing · Issue #22622 · mui/material-ui - GitHub
I am using React Testing Library, Is it possible to test in specific Material UI icon as ArrowLeft / ArrowRight instead of .MuiSvgIcon-root?...
Read more >Material Design Icons
Material Design Icons' growing icon collection allows designers and developers targeting various platforms to download icons in the format, color and size they ......
Read more >React Icon Component - Material UI - MUI
Standardized Material Icons exported as React components (SVG icons). ... For testing purposes, each icon exposed from @mui/icons-material has a data-testid ...
Read more >Material Icons Guide | Google Fonts
An overview of material icons—where to get them and how to integrate them with your projects. What are material icons? Material design system...
Read more >System icons - Material Design
Thumbs up icon using organic, natural shapes. Don'tDon't use gestural or loose organic shapes. Material Icons. Download icons and the icon web font....
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
Shouldn’t people be giving their semantic icons
titleAccess
prop and then querying for that? MUI’s own documents say you should usetitleAccess
for accessibility purposes.I realize this issue is closed, but here’s the language in question:
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
<use>
.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.