ByText

The getByText() function is used to get an element in React Testing Library based on the text value.

screen.getByText('Hello there');

It is quite a simple one to use, with a few advanced options. In this lesson we will go over them all.

Loading full lesson content & code...

Ready to try running tests for this lesson?