testing-library / testing-library/dom-testing-library
getByRole should not find the element with user custom and invalid ARIA role.
Open
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 3.3k
- Forks
- 474
- PR merge metrics
- No merged PRs in 30d
Description
@testing-library/domversion: -- 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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start from the getByRole('item') query shown in the issue and inspect how @testing-library/dom validates ARIA roles. Compare the behavior with the predefined roles linked in the issue, then add or update a regression test for an element using the custom invalid role; done means the query no longer finds it.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- accessibility, testing-qa
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100