testing-library / testing-library/testing-library-docs

ByText API page incorrectly states that it uses `textContent`

Open
#1,228 1 comment 0 reactions 0 assignees View on GitHub

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 textContent matching 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

  1. the docs reflect the actual implementation, which does not use textContent
  2. the implementation actually uses textContent for the matching.

Additional context

See also this issue on the dom-testing-library repo

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.