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

Querying hidden dialog by name fails #913

Closed
axelboc opened this issue Mar 19, 2021 · 1 comment
Closed

Querying hidden dialog by name fails #913

axelboc opened this issue Mar 19, 2021 · 1 comment

Comments

@axelboc
Copy link

axelboc commented Mar 19, 2021

  • @testing-library/dom version: 7.30.0
  • Testing Framework and version:
    • Jest: 26.6.0
  • DOM Environment:
    • JSDOM: 16.4.0

Relevant code or config:

export default () => (
  <>
    <div role="dialog" aria-label="Visible" />
    <div role="dialog" aria-label="Hidden" hidden />
  </>
);

What you did:

// This passes
expect(getByRole("dialog", { name: "Visible" })).toBeVisible();
expect(queryByRole("dialog", { name: "Hidden" })).toBeNull();
expect(queryAllByRole("dialog", { hidden: true })).toHaveLength(2);

// This fails
expect(getByRole("dialog", { name: "Hidden", hidden: true })).not.toBeVisible();

What happened:

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

Reproduction:

https://codesandbox.io/s/react-testing-library-demo-forked-imxvc?file=/src/hello.js

Problem description:

getByRole and the like don't seem to be able to find hidden dialogs by name.

@eps1lon
Copy link
Member

eps1lon commented Mar 19, 2021

Duplicate of #846

@eps1lon eps1lon marked this as a duplicate of #846 Mar 19, 2021
@eps1lon eps1lon closed this as completed Mar 19, 2021
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