-
Notifications
You must be signed in to change notification settings - Fork 470
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
Images with an empty alt attribute are not being assigned presentation
role (and are still being found by testing library even though they are hidden from the accessibility tree)
#1290
Comments
https://testing-library.com/docs/queries/byrole/#hidden If you set hidden to true elements that are normally excluded from the accessibility tree are considered for the query as well. The default behavior follows https://www.w3.org/TR/wai-aria-1.2/#tree_exclusion with the exception of role="none" and role="presentation" which are considered in the query in any case. So it's a normal behavior that you cant still find it. |
Thank you @Yohan27x ! It still seems like there is some strange behaviour here though - why does the image have a role of Additionally I have not edited the default value of
|
Afaik this was resolved in #1241 and is available in the alpha version 10 release 🙂 To quote @MatanBobi from similar issues:
Note: you will need to use resolutions/overrides to get the react package to use the alpha version of dom testing library at the moment. |
Thanks @cmorten! |
@testing-library/dom
version: latestRelevant code or config:
Component
Test file
What you did:
⬆️
What happened:
⬆️
Reproduction:
https://github.com/ahayes91/dom-testing-library-template
Problem description:
#1235 suggests that an
img
with an emptyalt
attribute should be given apresentation
role:Additionally, given that an image with alt="" removes it from the accessibility tree (screenreader users can't access it), I would expect that testing library should not be able to find it unless I include
hidden: true
in the query.The fact that the test "finds" the image when a screenreader user would not reduces our confidence that the automation is behaving correctly.
Suggested solution:
Not sure, it seems like a bug here but would need the maintainers to confirm!
Thank you!
The text was updated successfully, but these errors were encountered: