You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Testing Playground Fails to find role="listitem" #338
screen. getByRole('listitem') does nothing. It will correctly point out when clicking on the element that you should use getByRole('listitem') but then nothing happens when you do.
The error/notice is because there are multiple li elements matched to the same getByRole query. I guess we should make the query generator smarter and let it try less optimal queries in such cases (like the getByText).
I think what complicates things too is that (at least locally) list items don't have a name so you can't even use getByRole('listitem', {name: 'blah'})
The notice makes sense, but it would be nice to get a better error message when the query doesn't work, like in this case. It looks like nothing happens (unless i'm just missing it)
Reacted by Stephan Meijer, Nathan Vasse and Daniel Trone
Activity
ashleyryan commentedon Jul 23, 2021
🤦♀️ It's
getAllByRolenotgetByRolesmeijer commentedon Jul 23, 2021
Thanks for reporting!
The error/notice is because there are multiple
lielements matched to the samegetByRolequery. I guess we should make the query generator smarter and let it try less optimal queries in such cases (like thegetByText).ashleyryan commentedon Jul 23, 2021
I think what complicates things too is that (at least locally) list items don't have a
nameso you can't even use getByRole('listitem', {name: 'blah'})The notice makes sense, but it would be nice to get a better error message when the query doesn't work, like in this case. It looks like nothing happens (unless i'm just missing it)
smeijer commentedon Jul 23, 2021
Yeah, that makes sense. Would a message like this have been better?
Do you have any ideas/suggestions?
ashleyryan commentedon Jul 26, 2021
Yeah, a message like that would have been more helpful!