Skip to content

TestingLibraryElementError: Unable to find an element with the text - This could be because the text is broken up by multiple elements #1196

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

Closed
por14571-jochoa opened this issue Dec 15, 2022 · 8 comments

Comments

@por14571-jochoa
Copy link

Hello, I have a problem, i try to find some elements and gets a problem with the library, it doesn't find the queries.

If someone know about how to fix this problem.

TestingLibraryElementError: Unable to find an element with the text: /Texto./i. This could be because the text is broken up by multiple elements. In this case, you can provide a function for your text matcher to make your matcher more flexible.

image


❓ Support Forums

ISSUES WHICH ARE QUESTIONS WILL BE CLOSED

@timdeschryver
Copy link
Member

Closing this this because it isn't an issue.
If you need some help try our discord server or stackoverflow and share a reproducible example.

@por14571-jochoa
Copy link
Author

Thanks, I can solve the problem.

@jed212
Copy link

jed212 commented Feb 15, 2024

@por14571-jochoa How did you solve this problem?

Copy link

Uh oh! @snolan-ethika, the image you shared is missing helpful alt text. Check #1196 (comment).

Alt text is an invisible description that helps screen readers describe images to blind or low-vision users. If you are using markdown to display images, add your alt text inside the brackets of the markdown image.

Learn more about alt text at Basic writing and formatting syntax: images on GitHub Docs.

@snolan-ethika
Copy link

@por14571-jochoa How did you solve this problem?

I stumbled upon this thread, it kind of pointed me in the right direction finally... hope it helps you out https://stackoverflow.com/a/65951158

@thamaraRD
Copy link

Thanks, I can solve the problem.

Hello, tell us how you solved it, please

@snolan-ethika
Copy link

snolan-ethika commented Apr 4, 2024

Thanks, I can solve the problem.

Hello, tell us how you solved it, please

@thamaraRD I was able to solve this by manually setting the component's template with the necessary info, it doesn't feel right having to do this, but it was getting me by. I didn't spend a lot of time figuring out another way, but this helped me get it going.

ref: https://stackoverflow.com/a/65951158

@Victor-Ross
Copy link

Victor-Ross commented Apr 25, 2025

For anyone having this issue, if your div has a text like "Read our docs" and you search for getByText("docs") it will cause the error.
getByText expects for the entire text inside the node, so the correct is getByText("Read our docs")

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

6 participants