`*byRole("listbox")` does not properly query <select /> elements
See original GitHub issue@testing-library/dom
version:@testing-library/dom@8.11.0
- Testing Framework and version:
@testing-library/cypress@8.0.2
- DOM Environment: Cypress/browser (though the issue is reproduced in the Codesandbox that follows via Jest/JSDom)
Relevant code or config:
<label for="my-select">My Select</label>
<select id="my-select"></select>
// Using `dom-testing-library` via `cypress-testing-library`
cy.findByRole("listbox", { name: "My Select" }); // Doesn't work, element not found
cy.findByRole("combobox", { name: "My Select" }); // Does work! But this isn't the right ARIA role
What you did:
- Tried to query a select element using the analogous ARIA role for a select
What happened:
"combobox"
worked where it should have failed - the combobox role is distinct from the listbox role
Reproduction:
Problem description:
- A
<select />
should be query-able via*byRole("listbox")
Suggested solution:
- It looks like
aria-query
lists “listbox” as a valid role mapping to the select element - I would assume there is an integration problem with this library
Thanks for all of your great work on this library - it’s truly a game changer in the space 🎉
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:7 (4 by maintainers)
Top Results From Across the Web
ByRole | Testing Library
An element with the heading role can be queried by any heading level getByRole('heading') or by a specific heading level using the level...
Read more >byRole is not returning the DOM element - Stack Overflow
TestingLibraryElementError: Unable to find an accessible element with the role "listbox" There are no accessible roles.
Read more >`selectOptions` doesn't work when 'listbox' lives outside of ...
It's because the current logic looks for options inside the given select element, and in the given scenario, it can't find any and...
Read more >React Testing Library Confusion : r/reactjs - Reddit
Right now, I have just two tests: one checks for a non-multiple select that is not disabled. I find it with this: screen.queryByLabelText(" ......
Read more >ARIA: listbox role - Accessibility - MDN Web Docs - Mozilla
The listbox role is used for lists from which a user may select one or ... This is a space-separated list of element...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@MatanBobi we sure can! Appreciate your help and your work on this library. Happy New Year to you as well.
@nicklemmon I looked into the spec a little more and found this:
Since this is the wanted behavior, can we close this one? 😃