dom-testing-library icon indicating copy to clipboard operation
dom-testing-library copied to clipboard

getByRole should not find the element with user custom and invalid ARIA role.

Open mrdulin opened this issue 2 years ago • 1 comments

  • @testing-library/dom version: -
  • Testing Framework and version: -
  • DOM Environment: https://testing-playground.com/

Relevant code or config:

<div role='item'>
  apple
</div>

// query
screen.getByRole('item')

What happened:

The testing playground query the element successfully and told me the div element has an "item" role.

Problem description:

But the "item" role is not a pre-defined ARIA role, so I expect that screen.getByRole('item') should not find the element.

mrdulin avatar Dec 08 '22 09:12 mrdulin

This would block testing new roles (or experimental roles).

So if we start blocking (or warning about) unknown roles, we also need to add a configuration open to add available roles. People might not be able to upgrade Testing Library but are able to use new roles.

eps1lon avatar Dec 12 '22 13:12 eps1lon