Accessing queries with the screen object

In React Testing Library (RTL), the most useful object is the screen object.

The rest of this course covers the queries like getByText(). The typical way to get those query functions is via screen.getByText().

import { screen } from '@testing-library/react';

This is also covered in our main React testing course. If you've taken that already, you can skip this lesson.

We'll soon move into the more advanced query APIs.

In this lesson we'll do a quick recap of screen, and the different ways to access it.

Loading full lesson content & code...

Ready to try running tests for this lesson?