testing-library / testing-library/testing-library-docs
ByText API page incorrectly states that it uses `textContent`
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 479
- Forks
- 740
- PR merge metrics
- No merged PRs in 30d
Description
Describe the bug
The docs page for the byText API states that
[it] will search for all elements that have a text node with
textContentmatching the given TextMatch.
this is not true and will lead to confusion, since it's easy to find situations where trying to use getByText with the textContent of a node and not getting any match
To Reproduce
Here is a minimal codesandbox showing a case of getByText not matching the textContent of a node
Expected behavior
Either
- the docs reflect the actual implementation, which does not use textContent
- the implementation actually uses textContent for the matching.
Additional context
See also this issue on the dom-testing-library repo
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
Start with the ByText API documentation page and compare its textContent wording with the linked get-node-text.ts implementation. Review the related dom-testing-library issue #473 and the reproduction to establish the intended behavior; the work is done when the documentation and implementation agree and the reported mismatch is resolved.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100