material-ui icon indicating copy to clipboard operation
material-ui copied to clipboard

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

Open hbj opened this issue 1 year ago • 13 comments

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 avatar Apr 01 '25 07:04 hbj

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.

Janpot avatar Apr 01 '25 12:04 Janpot

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

hbj avatar Apr 01 '25 15:04 hbj

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

nicobatalla avatar Apr 01 '25 23:04 nicobatalla

Hi there, I got the same problem while upgrading MUI. Another idea, what about removing data-testid from development, too?

koooge avatar May 14 '25 13:05 koooge

Hi! Same as other devs have mentioned, we are using data-testid in our e2e testing. Is there an ETA for putting back the data-testid, or at least the flag to enable it, please? Thanks in advance.

gabrielsarriavillada avatar Jul 11 '25 09:07 gabrielsarriavillada

Bump, bringing it back would be great.

anthonyma94 avatar Jul 11 '25 16:07 anthonyma94

Indeed, this was a very useful feature. Any timeline to bring it back?

JBeaudaux avatar Jul 18 '25 09:07 JBeaudaux

This is the only thing that we need in a project to upgrade from v6 to v7. Please, consider bringing it back guys!

leonardocouy avatar Jul 18 '25 13:07 leonardocouy

Just wrote a few Playwright tests just to realize they don't pass in CI because of this 😁

I'm running my tests with a dev build locally to make it more convenient, but in CI I use the production build to get closer to the real thing.

ipeterov avatar Aug 05 '25 22:08 ipeterov

This caught me in CI as well - How about a theme property for toggling this?

Nthalk avatar Aug 24 '25 07:08 Nthalk

Bump this up. This breaks all automated playwrigth tests. Releasing production code takes a lot of time because all QA testing are now done manually...

feliciajacobsen avatar Sep 01 '25 08:09 feliciajacobsen

Any update on this issue? Miss this feature

valentinbesse avatar Sep 01 '25 09:09 valentinbesse

This behavior is really obnoxious. It will be extremely difficult to explain to devs writing playwright tests why their tests are working against a local dev server but failing against a production build in CI. I don't really care which behavior is used, just please make it consistent in all environments (or provide a way to make it consistent)

peter-olson-echo avatar Oct 14 '25 22:10 peter-olson-echo

Its nice we have control ourselves when to add it. But on generics, like inside Calendar the month selection testid is now gone and we have to write ugly things for it (aria-label).

Also its way confusing that on dev it shows. We have dev during local (when we write tests), but prod in ci. That makes everything confusing! Its there or its not. Simple. Please take into consideration these inner components from MUI itself. Like DataGrid Actions vertical icon ...

maapteh avatar Nov 10 '25 20:11 maapteh

We have dev during local (when we write tests), but prod in ci.

Yes, this ☝️

khitrenovich avatar Nov 10 '25 23:11 khitrenovich