testing-library / dom-testing-library

🐙 Simple and complete DOM testing utilities that encourage good testing practices.
https://testing-library.com/dom
MIT License
3.28k stars 467 forks source link

`getByRole("group")` can't match `address` tag #1277

Closed Tarektouati closed 1 year ago

Tarektouati commented 1 year ago

What you did:

I have React component that contains address tag :

// component.jsx
const Component = () => {
   return (
    <address>
          <span>street Name</span>
          <span>postal code and city</span>
          <span>country</span>
     </address>
    )
}

All i wanted is to test that component in spec file :

// component.test.jsx
within(screen.getByRole("group")).getByText("street Name");

What happened:

I was unable to match that address with role group

Problem description:

Following W3C address tag has role group, still I was unable to match it.

timdeschryver commented 1 year ago

To find the elements we make use of aria-query. The current version that we use (5.1.3) doesn't include the address field.

Upgrading aria-query to v5.3.0 solves this problem. This is included in our v10.0.0-alpha release.