Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
mrdulin opened this issue Dec 8, 2022 · 1 comment

Comments

@mrdulin
Copy link

mrdulin commented Dec 8, 2022

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.

@eps1lon
Copy link
Member

eps1lon commented Dec 12, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants