Skip to content
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

[icons] Remove SvgIcon data-testid in production #45333

Merged
merged 13 commits into from
Feb 19, 2025

Conversation

Janpot
Copy link
Member

@Janpot Janpot commented Feb 17, 2025

Removes the default data-testid prop when in production. Adds a section to the migration guide and remove the docs that describe this behavior.

@Janpot Janpot added the package: icons Specific to @mui/icons label Feb 17, 2025
@mui-bot
Copy link

mui-bot commented Feb 17, 2025

Netlify deploy preview

@material-ui/core: parsed: -0.07% 😍, gzip: -0.13% 😍

Bundle size report

Details of bundle changes (Toolpad)
Details of bundle changes

Generated by 🚫 dangerJS against dd6fa25

@EfstathiadisD
Copy link

EfstathiadisD commented Feb 18, 2025

Terrible! Terrible folks! What on earth are y folks doing over there?

@Janpot
Copy link
Member Author

Janpot commented Feb 18, 2025

What on earth are y folks doing over there?

@EfstathiadisD Trimming unnecessary bloat from production code, these test ids end up in server rendered html and potentially clash with user defined test ids.

The component still spreads props on the svg element, so a user defined testid will still end up there. Wouldn't that suffice for your use-case? Could you elaborate a bit more on why you think this should be kept?

@EfstathiadisD
Copy link

What on earth are y folks doing over there?

@EfstathiadisD Trimming unnecessary bloat from production code, these test ids end up in server rendered html and potentially clash with user defined test ids.

The component still spreads props on the svg element, so a user defined testid will still end up there. Wouldn't that suffice for your use-case? Could you elaborate a bit more on why you think this should be kept?

It was one of the most efficient ways to write tests!

We all had 1 way to test them, and now people are gonna start renaming it how they like.

I think options hurt the ecosystem more than strictness. I understand that it might not be beneficial but consider an approach where this Icons can have predefined data-testId.

Like a flag or something. And I suppose this goes to V7 as a breaking change. In our repo it about 35 instances of this.

And our apps aren't huge! Just IMHO!

@Janpot
Copy link
Member Author

Janpot commented Feb 18, 2025

Like a flag or something.

Would it work for you if we add the test id only when process.env.NODE_ENV is not 'production'?

@Janpot Janpot changed the title [icons] Remove default data-testid [icons] Remove SvgIcon data-testid in production Feb 18, 2025
@mnajdova
Copy link
Member

Add the test id only when process.env.NODE_ENV is not 'production'?

I think this is a good compromise, I can't imagine anyone wanting to have these in production.

@Janpot Janpot marked this pull request as ready for review February 18, 2025 14:00
@EfstathiadisD
Copy link

Like a flag or something.

Would it work for you if we add the test id only when process.env.NODE_ENV is not 'production'?

Yeah. That makes lots of sense! Thank You!!🙏

@zannager zannager requested a review from siriwatknp February 19, 2025 09:55
@Janpot Janpot merged commit 8da0670 into mui:master Feb 19, 2025
22 checks passed
NooBat pushed a commit to NooBat/material-ui that referenced this pull request Feb 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package: icons Specific to @mui/icons
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants