Closed
Description
DOM Testing Library
version: 9.5.0 (react library)node
version: Whatever CodeSandbox runs on for React sandboxesnpm
(oryarn
) version: Whatever CodeSandbox runs on for React sandboxes
Relevant code or config:
import React from "react";
import { render } from "@testing-library/react";
const Form = () => (
<div>
<form id='form1' title='form title'>
<p>Hi</p>
</form>
</div>
)
const wrapper = render(<Form />);
wrapper.getByRole('form');
What you did:
Trying to select the form element by role. This also fails with findByRole
.
What happened:
Error
Unable to find an accessible element with the role "form"
Here are the accessible roles:
document:
Name "":
<body />
Adding role='form'
to form element does find the form element but should not be required.
Reproduction:
https://codesandbox.io/s/falling-surf-0br51
Looks like bug was introduced in 16.4.1 as 16.4.0 works fine (with 9.4.1 version of @testing-library/react):
https://codesandbox.io/s/dom-testing-library-template-kzorw
Problem description:
Fails tests that are asserting that an accessible form is in the DOM.
Suggested solution:
aria-query looks to still be exporting form
in the roles map so that's probably not the issue. Other than that not had enough time to dig further.
Metadata
Metadata
Assignees
Labels
No labels