Why I don’t use test IDs: Adding test IDs all over my markup is a bad DX


Why I don’t use test IDs:

Adding test IDs all over my markup is a bad DX.

With a test ID, a test may pass when the user still doesn't see what's expected. That’s bad UX and DX. Seeing a test fail when an expected user-facing value doesn't exist is good DX.

If I think I need a test ID, it’s a sign my markup is insufficient, so I improve my markup instead.

If I think I need a test ID, it’s a sign I’m trying to test implementation details instead of UX. So I focus my test on UX instead.

Using accessible selectors encourages me to write accessible, semantic markup which enhances UX and DX.

View original on X