question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[material-icons] Testing

See original GitHub issue

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:

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:closed
  • Created 3 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
kylegoetzcommented, Nov 10, 2021

Shouldn’t people be giving their semantic icons titleAccess prop and then querying for that? MUI’s own documents say you should use titleAccess for accessibility purposes.

I realize this issue is closed, but here’s the language in question:

Semantic SVG icons
You should include the titleAccess prop with a meaningful value. The role="img" attribute and the <title> element are added so that your icons are correctly accessible.
3reactions
eps1loncommented, Sep 16, 2020

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found