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.
Sort: