---
title: "Test IDs are an a11y smell"
url: https://daily.dev/posts/test-ids-are-an-a11y-smell-wsju3vmxu
source_url: https://tkdodo.eu/blog/test-ids-are-an-a11y-smell
type: article
source: "TkDodo"
published: 2026-03-23T14:31:03.407Z
updated: 2026-03-23T14:31:30.281Z
tags: ["testing", "html", "accessibility"]
reading_time: 7
upvotes: 29
comments: 1
language: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Test IDs are an a11y smell

**[TkDodo](https://daily.dev/sources/tkdodo)** · 7 min read · 29 upvotes · 1 comments

## Summary

Using data-testid attributes in tests is an accessibility smell because users can't see or interact with test IDs. Role-based selectors (via Testing Library or Playwright) are superior because they mirror how real users interact with apps, catch inaccessible markup like clickable divs lacking semantic roles, and provide implicit a11y testing. If a role-based selector can't find an element, that's a signal the UI itself is inaccessible. Practical tips include using semantic HTML for implicit ARIA roles, associating form labels, using headings and landmarks, leveraging Testing Playground, and navigating with the keyboard to catch issues.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://tkdodo.eu/blog/test-ids-are-an-a11y-smell>

## Community discussion

Top comments from developers on daily.dev.

**@0x\_rorschach** · 2 upvotes

> I can't tell you the amount of times I've had an agent write tests only to get stuck and start using `data-testid` workarounds that end up not testing the implementation very well

## Similar posts on daily.dev

- [Why You Should Use Locators Instead of Text in Your Tests](https://daily.dev/posts/why-you-should-use-locators-instead-of-text-in-your-tests-vkbipoegx) · TypeScript.TV · 2 upvotes · 0 comments
- [Issue \#468: Why test IDs are an accessibility code smell — React Status](https://daily.dev/posts/issue-468-why-test-ids-are-an-accessibility-code-smell-react-status-ehyihla1m) · React Status · 0 upvotes · 0 comments

---

Tags: [#testing](https://daily.dev/tags/testing), [#html](https://daily.dev/tags/html), [#accessibility](https://daily.dev/tags/accessibility)

[View this post on daily.dev](https://daily.dev/posts/test-ids-are-an-a11y-smell-wsju3vmxu)
