Skip to content
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

Can't getByRole with name and hidden: true #1008

Closed
diegohaz opened this issue Jan 3, 2022 · 1 comment
Closed

Can't getByRole with name and hidden: true #1008

diegohaz opened this issue Jan 3, 2022 · 1 comment

Comments

@diegohaz
Copy link

diegohaz commented Jan 3, 2022

  • @testing-library/react version: 12.1.2
  • Testing Framework and version: react-scripts 5.0.0
  • DOM Environment: jsdom in react-scripts 5.0.0

What you did:

I'm trying to get a hidden element using getByRole, passing a name and setting hidden to true.

What happened:

It looks like the element name is empty when the element is hidden even when passing hidden: true to the options. Not sure if it's intended, but that's not what I expect. The same happens with aria-label.

This is the error:

Unable to find an element with the role "dialog" and name "Title"

Here are the available roles:

  dialog:

  Name "":
  <div
    aria-labelledby="title"
    hidden=""
    role="dialog"
  />

Reproduction:

https://codesandbox.io/s/react-testing-library-does-not-find-hidden-element-by-accessible-name-6ncd2

@MatanBobi
Copy link
Member

Hi @diegohaz, thanks for taking the time to open this one :)
I'm closing this as duplicate of testing-library/dom-testing-library#846
You can track the progress in there.
Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants