Closed
Description
@testing-library/dom
version: 16.9- Testing Framework and version: 9.2
- DOM Environment: 4.1.0
See codesandbox
Relevant code or config:
test("getByRole", () => {
render(
<div>
<strong>hello</strong>
</div>
);
screen.getByRole("strong"); // errors
});
What you did:
What happened:
Unable to find an accessible element with the role "strong"
Here are the accessible roles:
document:
Name "":
<body />
--------------------------------------------------
<body>
<div>
<div>
<strong>
hello
</strong>
</div>
</div>
</body>
Reproduction:
https://codesandbox.io/s/react-testing-library-demo-forked-lzjrl1?file=/src/__tests__/getByRole.js
Problem description:
According to https://testing-library.com/docs/queries/byrole/, we should use the HTMLElement's role. According to this table, <strong>
has an implicit role of strong
but it does not get found
Metadata
Metadata
Assignees
Labels
No labels