Skip to content

Possibility to opt out of removing data-testid from icons on production #45777

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

Open
hbj opened this issue Apr 1, 2025 · 4 comments
Open

Possibility to opt out of removing data-testid from icons on production #45777

hbj opened this issue Apr 1, 2025 · 4 comments
Assignees
Labels
package: icons Specific to @mui/icons

Comments

@hbj
Copy link

hbj commented Apr 1, 2025

Summary

Removing the data-testid from icons only for production is very confusing because if you run e2e tests with the production version, as we do, you might have your tests running locally when implementing them, because you use the dev version, but have them fail on CI that uses the prod version. If you forget about this point you might have to wait for the CI to finish to figure out the issue. This also makes debugging very difficult unless you're aware of this subtlety.

Is it possible to add some flag/env var to opt out of removing the data-testid?

Related PR.

Examples

No response

Motivation

No response

Search keywords: icons, testid, data-testid

@hbj hbj added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Apr 1, 2025
@Janpot Janpot self-assigned this Apr 1, 2025
@Janpot Janpot added package: icons Specific to @mui/icons and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Apr 1, 2025
@Janpot
Copy link
Member

Janpot commented Apr 1, 2025

The decision to only show testids in dev was an idea to find middle ground between users relying on them for tests and avoiding them ending up in production ssr content. For now the remedy would be to provide your own data-testid to the icons you want to test. We're exploring a property to enable this testid globally.

@hbj
Copy link
Author

hbj commented Apr 1, 2025

This property is exactly what I'm asking for, thanks 🙌

@hbj hbj closed this as completed Apr 1, 2025
@Janpot Janpot reopened this Apr 1, 2025
@mui mui deleted a comment from github-actions bot Apr 1, 2025
@nicobatalla
Copy link

I am currently updating a production app to MUI v7 and this is the main blocker we are getting at this point. We do use a few of the default data-testid in our e2e suites, and it would be much appreciated to be able to opt-out

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

No branches or pull requests

3 participants