-
Notifications
You must be signed in to change notification settings - Fork 467
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('form') should work without "name" attribute #937
Comments
@kentcdodds I think this is expected, or at least that's what the spec says. |
Ah! That's interesting. So this sounds more like a bug in Chrome's accessibility devtools than a DTL bug 😅 Thanks for finding that @mt9eet! 👏 |
@ahsatha thanks for reaching out. |
This is a good gotcha to mention in the docs pages somewhere. |
@alexkrolick that's actually already in the docs page in the Do you think that's enough? |
- cleanup is done automatically after each test - only forms with an accessible name have the role "form" Check: https://www.w3.org/TR/html-aria/#docconformance and testing-library/dom-testing-library#937
- cleanup is done automatically after each test - only forms with an accessible name have the role "form" Check: https://www.w3.org/TR/html-aria/#docconformance and testing-library/dom-testing-library#937 - waitForElement has been removed, now we can use find* variants, which return a promise, or waitFor
- cleanup is done automatically after each test - only forms with an accessible name have the role "form" Check: https://www.w3.org/TR/html-aria/#docconformance and testing-library/dom-testing-library#937 - waitForElement has been removed, now we can use find* variants, which return a promise, or waitFor
- cleanup is done automatically after each test - only forms with an accessible name have the role "form" Check: https://www.w3.org/TR/html-aria/#docconformance and testing-library/dom-testing-library#937
- cleanup is done automatically after each test - only forms with an accessible name have the role "form" Check: https://www.w3.org/TR/html-aria/#docconformance and testing-library/dom-testing-library#937 - waitForElement has been removed, now we can use find* variants, which return a promise, or waitFor
- cleanup is done automatically after each test - only forms with an accessible name have the role "form" Check: https://www.w3.org/TR/html-aria/#docconformance and testing-library/dom-testing-library#937 - waitForElement has been removed, now we can use find* variants, which return a promise, or waitFor
- cleanup is done automatically after each test - only forms with an accessible name have the role "form" Check: https://www.w3.org/TR/html-aria/#docconformance and testing-library/dom-testing-library#937
- cleanup is done automatically after each test - only forms with an accessible name have the role "form" Check: https://www.w3.org/TR/html-aria/#docconformance and testing-library/dom-testing-library#937 - waitForElement has been removed, now we can use find* variants, which return a promise, or waitFor
- cleanup is done automatically after each test - only forms with an accessible name have the role "form" Check: https://www.w3.org/TR/html-aria/#docconformance and testing-library/dom-testing-library#937 - waitForElement has been removed, now we can use find* variants, which return a promise, or waitFor
- cleanup is done automatically after each test - only forms with an accessible name have the role "form" Check: https://www.w3.org/TR/html-aria/#docconformance and testing-library/dom-testing-library#937
- cleanup is done automatically after each test - only forms with an accessible name have the role "form" Check: https://www.w3.org/TR/html-aria/#docconformance and testing-library/dom-testing-library#937 - waitForElement has been removed, now we can use find* variants, which return a promise, or waitFor
- cleanup is done automatically after each test - only forms with an accessible name have the role "form" Check: https://www.w3.org/TR/html-aria/#docconformance and testing-library/dom-testing-library#937 - waitForElement has been removed, now we can use find* variants, which return a promise, or waitFor
- cleanup is done automatically after each test - only forms with an accessible name have the role "form" Check: https://www.w3.org/TR/html-aria/#docconformance and testing-library/dom-testing-library#937
- cleanup is done automatically after each test - only forms with an accessible name have the role "form" Check: https://www.w3.org/TR/html-aria/#docconformance and testing-library/dom-testing-library#937 - waitForElement has been removed, now we can use find* variants, which return a promise, or waitFor
- cleanup is done automatically after each test - only forms with an accessible name have the role "form" Check: https://www.w3.org/TR/html-aria/#docconformance and testing-library/dom-testing-library#937 - waitForElement has been removed, now we can use find* variants, which return a promise, or waitFor
- cleanup is done automatically after each test - only forms with an accessible name have the role "form" Check: https://www.w3.org/TR/html-aria/#docconformance and testing-library/dom-testing-library#937
- cleanup is done automatically after each test - only forms with an accessible name have the role "form" Check: https://www.w3.org/TR/html-aria/#docconformance and testing-library/dom-testing-library#937 - waitForElement has been removed, now we can use find* variants, which return a promise, or waitFor
- cleanup is done automatically after each test - only forms with an accessible name have the role "form" Check: https://www.w3.org/TR/html-aria/#docconformance and testing-library/dom-testing-library#937 - waitForElement has been removed, now we can use find* variants, which return a promise, or waitFor
- cleanup is done automatically after each test - only forms with an accessible name have the role "form" Check: https://www.w3.org/TR/html-aria/#docconformance and testing-library/dom-testing-library#937
- cleanup is done automatically after each test - only forms with an accessible name have the role "form" Check: https://www.w3.org/TR/html-aria/#docconformance and testing-library/dom-testing-library#937 - waitForElement has been removed, now we can use find* variants, which return a promise, or waitFor
- cleanup is done automatically after each test - only forms with an accessible name have the role "form" Check: https://www.w3.org/TR/html-aria/#docconformance and testing-library/dom-testing-library#937 - waitForElement has been removed, now we can use find* variants, which return a promise, or waitFor
- cleanup is done automatically after each test - only forms with an accessible name have the role "form" Check: https://www.w3.org/TR/html-aria/#docconformance and testing-library/dom-testing-library#937
- cleanup is done automatically after each test - only forms with an accessible name have the role "form" Check: https://www.w3.org/TR/html-aria/#docconformance and testing-library/dom-testing-library#937 - waitForElement has been removed, now we can use find* variants, which return a promise, or waitFor
- cleanup is done automatically after each test - only forms with an accessible name have the role "form" Check: https://www.w3.org/TR/html-aria/#docconformance and testing-library/dom-testing-library#937 - waitForElement has been removed, now we can use find* variants, which return a promise, or waitFor
Uh oh! @challet, the image you shared is missing helpful alt text. Check #937 (comment). Alt text is an invisible description that helps screen readers describe images to blind or low-vision users. If you are using markdown to display images, add your alt text inside the brackets of the markdown image. Learn more about alt text at Basic writing and formatting syntax: images on GitHub Docs. |
Thanks @challet. This looks like an issue with Maybe @jlp-craigmorten will know? |
Exactly as @MatanBobi suggests, the role of
it seems. So See also #1293 which might be a better place to track this rather this older closed issue? There is an open draft MR A11yance/aria-query#547 to try address the fact that the implicit form role conditions appear to have changed whereby it is not now necessary to name a form to get a |
@testing-library/dom
version: allRelevant code or config:
What you did:
Originally I thought that a form didn't actually have the accessible role "form" unless they had a name, but I just did a quick check in the devtools and that appears to not be the case:
I did a bit of research and it appears there aren't any strong reasons to use a
name
attribute for a form, so it seems an odd limitation for us to have.What happened:
Test fails.
Reproduction:
Put the above snippet in any jest environment you have working with testing library.
Alternatively, you'll find the same behavior in the browser as well: https://jsbin.com/ceyifo/edit?html,output
Problem description:
It seems odd to me that a form requires a
name
attribute to be retrievable by a role query when it appears that the browser considers it to have a role ofform
.Suggested solution:
Update
getByRole
to match forms without aname
.The text was updated successfully, but these errors were encountered: