Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ByText API page incorrectly states that it uses textContent #1228

Open
agos opened this issue Mar 1, 2023 · 1 comment
Open

ByText API page incorrectly states that it uses textContent #1228

agos opened this issue Mar 1, 2023 · 1 comment

Comments

@agos
Copy link

agos commented Mar 1, 2023

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

@MatanBobi
Copy link
Member

Thanks for opening this one @agos.
The code actually does use textContent, except it also gets it from the children and tries to concat them. In some cases, that behavior might have issues but I'm not sure if writing about those issues in the docs will help or cause more confusion.
The docs are there to give you the context and information about the behavior and not include a "pseudo-code" of the function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants