TestingLibraryElementError: Unable to find an element with the text - This could be because the text is broken up by multiple elements
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.

❓ Support Forums
- Discord https://discord.gg/testing-library
- Stack Overflow https://stackoverflow.com/questions/tagged/react-testing-library
ISSUES WHICH ARE QUESTIONS WILL BE CLOSED
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.
Thanks, I can solve the problem.
@por14571-jochoa How did you solve this problem?
Uh oh! @snolan-ethika, the image you shared is missing helpful alt text. Check https://github.com/testing-library/dom-testing-library/issues/1196#issuecomment-1998406417.
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.
@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
Thanks, I can solve the problem.
Hello, tell us how you solved it, please
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
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")