According to the Testing Library documentation, the byRole queries should return elements based on their default role.
For example, if I my DOM has header tags (h1,h2, etc), queryAllByRole(container, 'header'), should return all the header elements in the container, but instead always returns an empty array. I have tried to get this work with several different tags and their default roles and all have failed.
For example, if I run the following in Jest I get the expected results:
const articleCount = await rendered.queryAllByRole('article'); console.log( `article count = ${articleCount.length}`)
But the equivalent in Playwright using this library, the returned array is always empty:
const root = await page.locator(ROOT_SEL); const itemArticles = await queryAllByRole(root, 'article'); console.log( `items articles length = ${itemArticles.length}`);
The byRole queries should be using the accessibility tree to determine roles, but they appear to just be using the "role" attribute on a tag.