testing-library / testing-library/react-testing-library
Id selector square brackets not escaped correctly
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 19.7k
- Forks
- 1.2k
- Avg merge
- 3d 16h
- Merged PRs (30d)
- 1
Description
"@testing-library/jest-dom": "^6.6.3",
"@testing-library/react": "11.2.6",
"@testing-library/react-hooks": "5.1.2",
"@testing-library/user-event": "^14.5.2",
"vitest": "^3.0.5",
"react": "17.0.2",
"react-dom": "17.0.2",
node: v20.18.1
Relevant code or config:
<input type="search" class="input" id="artikeltyp.geraetedatenKommunikationsGeraeteKomponententypen[1].anschluss" disabled="" style="anchor-name: --useCSSAnchor-10;" value="" placeholder="Klemmenblock">
What you did:
expect(
component.getByPlaceholderText('Klemmenblock'),
).toBeVisible();
What happened:
SyntaxError: 'input#artikeltyp.geraetedatenKommunikationsGeraeteKomponententypen[1].anschluss.input :focus-visible' is not a valid selector
Reproduction:
Problem description:
The id selector square brackets are not escaped by testing library.
Suggested solution:
The id selector square brackets should be escaped by testing library.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Use the shown input id and getByPlaceholderText('Klemmenblock') call as the starting case. Trace how the testing library builds the focus-visible selector and verify that square brackets are escaped without breaking existing selector behavior. Done means the call no longer throws a SyntaxError for this id.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, react
- Domain
- frontend, testing
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100