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's error message is incorrect on button with role "tab" #553
Comments
Thanks for the report. That is indeed weird. You should start with adding a test to src/tests/role.js. The code for ByRole lives in src/queries/role.js. |
It looks like there are actually 2 issues here. The first is the library aria-query, which we're using to get a map of the elements to their possible roles. Under elementRoles, the button element only has the role "button". This would need to be extended to include other roles, such as tab. The second is that the matches function correctly determines that |
Just dug a bit more into this. Therefore, the solution would be to put up an issue and PR in the aria-query library, and once that is merged, update the version used by dom-testing-library. If you're happy with that, @eps1lon, I can go ahead and do that. |
Great investigation! We do sort by specificity: dom-testing-library/src/role-helpers.js Line 118 in 429de04
dom-testing-library/src/role-helpers.js Lines 92 to 94 in 429de04
|
That would make sense. It looks like that logic is still manipulating the map from aria-query, so it still wouldn't include |
|
When I
I get the following list: elementRoleList.txt which doesn't include tab, or a selector called button[role="tab"]. Am I missing something? |
🎉 This issue has been resolved in version 7.5.3 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
DOM Testing Library
version: 5.5.0node
version: 13.12.0npm
(oryarn
) version: 1.22.4Relevant code or config:
What happened:
The test (correctly) failed because it could not find an element with the role of button (the button has a role of "tab"). However, when the error message listed the accessible roles, it listed the button's role under "button":
Reproduction:
Code Sandbox
Problem description:
The current behaviour is confusing because the error message says there is no element with the role of "button" and then shows that there is an element with the role of "button".
Suggested solution:
Buttons with other roles (e.g. tab) should be shown under their correct roles in the error message.
I'm happy to put up a PR for this but would need pointing in the right direction as I'm unfamiliar with the code 😁
The text was updated successfully, but these errors were encountered: