Key Concepts

Review core concepts you need to learn to master this subject

What is React Testing Library?

React Testing Library (RTL) is a library for testing React applications. React Testing Library focuses on testing components from the end-user’s experience rather than testing the implementation and logic of the underlying React components.

React Testing Library
Lesson 1 of 1
  1. 1
    In this lesson, you will learn how to test your React components with the React Testing Library (RTL). Remember, we need…
  2. 2
    In order to use React Testing Library, we will need to include the @testing-library/react package in our project by using npm like so: npm install @testing-library/react –save-dev Once we have …
  3. 3
    Now that we know how to set up RTL, we can finally start testing our React components. To do so, we first have to query for and extract the DOM nodes from our virtually rendered components. Then, w…
  4. 4
    Now that we know how to perform queries with .getByX methods, it is time for us to move on to the other query method variants. RTL has two other categories of query methods called .queryByX and .fi…
  5. 5
    So far we’ve learned how to query and extract the different DOM nodes from our React components. Now, it’s time for us to learn how to mimic user interactions e.g. clicking a checkbox, typing text,…
  6. 6
    In the previous exercise we’ve learned about the .findByX query methods that allows us to test components that render asynchronously. But what about components that disappear asynchronously? Look…
  7. 7
    Good job! We can now use React Testing Library (RTL) to test our React components. Let’s quickly review what we’ve learned so far: - React Testing Library allows us to test React components by mim…

What you'll create

Portfolio projects that showcase your new skills

Pro Logo

How you'll master it

Stress-test your knowledge with quizzes that help commit syntax to memory

Pro Logo