Closed
Description
dom-testing-library
version: 1.1.0node
version: N/Anpm
(oryarn
) version: N/A
Relevant code or config
import { getByTestId } from "dom-testing-library";
document.getElementById("test").innerHTML = `
<div data-testid="supertest-123"></div>
`;
document.getElementById("output").innerHTML = `
${getByTestId(document, "tEsT")
.outerHTML.replace(/</g, "<")
.replace(/>/g, ">")}
`;
What you did:
- Added an element with
data-testid="supertest-123"
to an empty DOM. - Queried the DOM via
getByTestId
by string"tEsT"
.
What happened:
The element with data-testid="supertest-123"
was found.
Reproduction repository:
https://codesandbox.io/s/pwrpl1yy9x?module=%2Fsrc%2Findex.js
Problem description:
The current behavior is unexpected, the identifiers aren't supposed to be matched partially and case-insensitively.
Suggested solution:
Use case-sensitive full-string match in queryByTestId
, getByTestId
.