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...

Share this lessonTweet (X) it

Invite a teammate to learn with you by sharing this lesson or dropping the link in your team chat.

Ready to try running tests for this lesson?