-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
findByRole doesn't find the role #1248
Comments
Experiencing similar thing with I'm thinking about filing an issue on
Update: Filed an issue on @testing-library/dom that might be related: |
It seems I'm using the latest version of npm ls @testing-library/dom
perses-dev@0.1.0 /Users/ahusson/workspace/go/src/perses/perses/ui
├─┬ @perses-dev/storybook@0.41.1 -> ./storybook
│ └─┬ @storybook/testing-library@0.2.2
│ └── @testing-library/dom@9.3.3 deduped
├─┬ @testing-library/react@14.1.0
│ └── @testing-library/dom@9.3.3
└─┬ @testing-library/user-event@14.5.1
└── @testing-library/dom@9.3.3 |
I tried using what you suggested to override the version and now I'm using the version 9.3.1. npm ls @testing-library/dom
perses-dev@0.1.0 /Users/ahusson/workspace/go/src/perses/perses/ui
├─┬ @perses-dev/storybook@0.41.1 -> ./storybook
│ └─┬ @storybook/testing-library@0.2.2
│ └── @testing-library/dom@9.3.1 deduped
├─┬ @testing-library/react@14.1.0
│ └── @testing-library/dom@9.3.1 overridden
└─┬ @testing-library/user-event@14.5.1
└── @testing-library/dom@9.3.1 But unfortunately I'm experiencing the same issue :(. |
OK, it might be unrelated to the issue I was seeing with |
I'm experiencing the same issue with a react-native application. Weirdly though, using the new API with |
I looked in to this a little bit and found it has to do with not getting the accessible name for the element, seemingly due to an issue with handling of the Failing caseWhen the As in the example given by @Nexucis... the element has
Example test code added to
Test output
Passing caseWhen the For example
Example test code added to
Alternatively setting In this particular case I also found setting the following got the test to pass by wrapping it in a label element.
Note this resulted in the combobox div having |
I dug in to this further and created several test cases below for @testing-library/dom to Interestingly it was possible to get the element by labelText and then filter it to the role using the matching selector. However, attempts to get by role with name failed with an error
which points to https://github.com/eps1lon/dom-accessibility-api/blob/0f33d2d73af4bfcf7f3bc53e13e05dedd07ebc77/sources/util.ts#L101 Tests
Test Output
|
amazing investigation @agentdylan !! Thank you so much for taking time to find a workaround. |
Happy to help! yeah, not sure what the complete fix is exactly though and suspect the issue/fix may be in another dependency. Hopefully my investigation is useful and perhaps someone with more familiarity in this area will be able to figure it out 😄 |
I believe I've traced it to the root cause of the issue and filed an issue on the dependency. It is unique to the It is interesting there was also issues with my tests using the role |
Fixes #752. Had to upgrade react monorepo. Had to apply workaround found at testing-library/react-testing-library#1248 (comment).
Fixes #752. Had to upgrade react monorepo. Had to apply workaround found at testing-library/react-testing-library#1248 (comment).
Thanks @agentdylan the |
@testing-library/react
version: 14.1.0Relevant code or config:
https://github.com/perses/perses/blob/nexucis/update-dev-deps/ui/plugin-system/src/components/PluginKindSelect/PluginKindSelect.test.tsx#L54-L55
What you did:
I just upgraded the testing-library from the version 13 to 14 and somehow the function
findByRole
doesn't find my component but in the error console it shows it.I tried to increase the timeout, I also tried a regexp for the name. It doesn't work.
I have also taken a look at #835 but I'm not using a fancy role here. So I guess my issue is somewhere else.
As a side note, the role attributed previously was
button
and now it iscombobox
. I don't know if it's really important to notice it.What happened:
Here the result shown in the console once the test is crashing.
But we clearly see that the component with the role
combobox
and the nameErnie Variable 1
is there. I know the component is loaded asynchronously, so this combobox with the accurate name is not present immediately but even after increasing the timeout it is still crashing.So I'm not sure what is wrong in my component or even in my usage of the testing-library.
The text was updated successfully, but these errors were encountered: