testing-library / testing-library/dom-testing-library
should getByText return a title?
Open
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 3.3k
- Forks
- 474
- PR merge metrics
- No merged PRs in 30d
Description
@testing-library/domversion: latest master- Testing Framework and version: node, jest 12.x, 26.x
- DOM Environment:
Relevant code or config:
test('foo', () => {
renderIntoDocument(` <svg>
<title data-testid="svg">Close</title>
<g><path /></g>
</svg>`)
screen.debug(screen.getByText('Close'))
})
What you did:
called screen.getByText
What happened:
I got back the title... but shouldn't getByText be accessible to everyone? If it's hidden, it won't be accessible to sighted users.
Reproduction:
Problem description:
Suggested solution:
have getByText ignore <title> elements.
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
Reproduce the SVG example using screen.getByText('Close') and inspect the query behavior for the <title> element. Determine whether title elements should be excluded from getByText, then add coverage showing the expected result and run the relevant test suite.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- testing-qa
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100