-
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
...ByRole with paragraph
not working
#1234
Comments
For anyone running into this as well: Our workaround, for the moment at least, is to use the |
Hi @thany :)
Since dom-testing-library is a library for dom testing, the separation of concerns is such that aria-query follows the spec and we're using it so we won't have any spec logic, rather only a set of utilities for testing. I'm keeping this issue open until we'll upgrade aria-query. |
See, I knew there was an explanation. I hope for your sake it's not actually as complicated as my brain is comprehending it. Like I said, it's probably the heat 😀 Anyway, thanks for picking this up as quickly as you did 👍🏻 |
This comment was marked as outdated.
This comment was marked as outdated.
🎉 This issue has been resolved in version 10.0.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
In case anyone else runs into this issue, I couldn't get this to work after the fix was implemented until I updated @testing-library/react from v14 -> v16. |
I get
|
Similar to what I had. I also updated jsdom from v23 -> v24.1. |
I'm on |
@thathurtabit can you please open a new issue with a reproduction so we'll be able to help? |
Seems you're right @MatanBobi - I tried to recreate the issue here - but the test passes. |
@testing-library/dom
version: 9.3.0Relevant code or config:
What you did:
Just searching for paragraphs in any rendered HTML, will fail. How the HTML gets rendered (React in this particular case) I don't think that matters anything.
What happened:
It won't find any elements by the role
paragraph
. Other roles are found successfully.Reproduction:
https://codesandbox.io/s/react-testing-library-demo-forked-z4mf2z?file=/src/__tests__/hello.js
I've made the Hello component output a
<p>
and looked it up usingqueryAllByRole('paragraph')
, which returns an empty array. I would expect an array of one item, namely the paragraph element.Problem description:
I need to test if a paragraph, when certain conditions are met, is present or absent in the resulting render. The documentation on
...ByRole
links to the specification on W3C where thep
element is listed has having theparagraph
role. So, it should work.Suggested solution:
I've been digging around to figure out how the role of a given element is calculated, and to me it seems rather over-engineered. There's probably a good reason for it though, but I did end up at aria-query from where you seem to be fetching a list of what appears to be a mapping between elements and roles?
Ultimately I couldn't figure out how and where this list is getting built. I don't mean to patronise, but it seems pretty basic to me, having a map of tagName=>role floating somwhere. It could be the heat wave hitting my brain though 😣
The text was updated successfully, but these errors were encountered: