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
const{ getByRole }=renderWithProviders(<div><sectionstyle={{visibility: "hidden"}}><h1>{"Jane Doe"}</h1></section></div>);awaitwaitFor(()=>{getByRole("heading",{name: "Jane Doe",hidden: true});// This times out :(});
What you did:
I'm testing the presence of an element that has a parent with the style visibility: "hidden" using a ByRole query and the hidden option set to true.
Elements, including their descendent elements, that have host language semantics specifying that the element is not displayed, such as CSS display:none, visibility:hidden, or the HTML hidden attribute.
What happened:
The test failed and the element was not found by the byRole query when the parent (or even the specific element) has the visibility: "hidden" style
According to the documentation, the hidden behavior follows https://www.w3.org/TR/wai-aria-1.2/#tree_exclusion, which says that elements are not included in the accessibility tree with CSS such as visibility: "hidden". So in this case, setting hidden to true should work 🙂
Suggested solution:
To be honest, I haven't checked the code or what the issue could be. But I'll be happy to help out and open a PR if someone can point me in the right direction 🙂
The text was updated successfully, but these errors were encountered:
@testing-library/dom
version: 8.2.0Relevant code or config:
What you did:
I'm testing the presence of an element that has a parent with the style
visibility: "hidden"
using a ByRole query and thehidden
option set totrue
.What happened:
The test failed and the element was not found by the
byRole
query when the parent (or even the specific element) has thevisibility: "hidden"
styleReproduction:
I forked the sandbox, but to be honest it was behaving in kind of weird. Anyways, the issue is really easy to reproduce and here's the link:
https://codesandbox.io/s/react-testing-library-demo-forked-1s48z?file=/src/__tests__/hello.js
Problem description:
According to the documentation, the
hidden
behavior follows https://www.w3.org/TR/wai-aria-1.2/#tree_exclusion, which says that elements are not included in the accessibility tree with CSS such asvisibility: "hidden"
. So in this case, settinghidden
totrue
should work 🙂Suggested solution:
To be honest, I haven't checked the code or what the issue could be. But I'll be happy to help out and open a PR if someone can point me in the right direction 🙂
The text was updated successfully, but these errors were encountered: