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
I want to check my component to have the accessible UI inside: expect(screen.getByRole("term", { name: "foo" })).toBeInTheDocument();
What happened:
RTL is unable to find the an HTML component with that role and term:
TestingLibraryElementError: Unable to find an accessible element with the role "term" and name "foo"
Here are the accessible roles:
term:
Name "":
<dt />
Name "":
<dt />
--------------------------------------------------
definition:
Name "":
<dd />
Name "":
<dd />
--------------------------------------------------
Ignored nodes: comments, script, style
[logging continues but is irrelevant]
Reproduction:
it can be reproduced in this testing library playground:
I would like to be able to check that this specific component exists with this accessible role and this name. the first dt can be found with this role and name using screenreaders and can be viewed in the accessibility tree in devtools of the browser, but testing library does not handle this expectation as this works in a production situation.
As per https://testing-library.com/docs/queries/about#priority I prefer to use getByRole, but for now I can use the following (less accessibility using/testing) alternative: expect(screen.getByText("foo", { selector: "dt" })).toBeInTheDocument();
Suggested solution:
have expect(screen.getByRole("term", { name: "foo" })).toBeInTheDocument(); succeed for the given component.
The text was updated successfully, but these errors were encountered:
using vitest 3.1.2
Relevant code or config:
testing playground reproducible:
https://testing-playground.com/gist/9a5293d2879a9166bcaa48dc520982ae/a3984c7d21b6ff2c670a9eb95df5163713d0a5b5
What you did:
I want to check my component to have the accessible UI inside:
expect(screen.getByRole("term", { name: "foo" })).toBeInTheDocument();
What happened:
RTL is unable to find the an HTML component with that role and term:
Reproduction:
it can be reproduced in this testing library playground:
https://testing-playground.com/gist/9a5293d2879a9166bcaa48dc520982ae/a3984c7d21b6ff2c670a9eb95df5163713d0a5b5
Problem description:
I would like to be able to check that this specific component exists with this accessible role and this name. the first dt can be found with this role and name using screenreaders and can be viewed in the accessibility tree in devtools of the browser, but testing library does not handle this expectation as this works in a production situation.
As per https://testing-library.com/docs/queries/about#priority I prefer to use getByRole, but for now I can use the following (less accessibility using/testing) alternative:
expect(screen.getByText("foo", { selector: "dt" })).toBeInTheDocument();
Suggested solution:
have
expect(screen.getByRole("term", { name: "foo" })).toBeInTheDocument();
succeed for the given component.The text was updated successfully, but these errors were encountered: