Unable to find an element with the text: “myText” error when using react-testing-library
getByText looks for the text inside a node. So in this example: <div class=”foo”>bar</div> the text is bar. getByAltText is the best way to find an image. Another way is to use getByTestId. What if you must find an element by class? In these cases, you can use container which is returned by render. container … Read more