US $19.97

Testing React Apps with React Testing Library (RTL)

——   Created by David Armendariz

Learn how to test React components with React Testing Library, the recommended library from Facebook for testing.

Share this course:

NEW
Course
21
Lessons
2h 36m
Lesson time
beginner
Skill level

More about this course

Welcome to testing React components with React Testing Library! In this course, you will learn lots of things. You will learn:

  • The principles of Test Driven Development
  • Know what is React Testing Library (RTL) and its differences with Enzyme (another popular test framework for React)
  • Understand how Create React App (CRA) works.
  • Understand how Jest works with RTL
  • How to test with RTL and query elements with:
  • getBy, queryBy, findBy, getAllBy, queryAllBy, findAllBy
  • How to simulate user interaction with the fireEvent API
  • How to simulate user interaction with the userEvent API
  • Testing components in isolation (unit tests)
  • Learn about coverage and debugging
  • How to mock 3rd party libraries like Axios and mock a GET request
  • Learn about the pitfalls of CRA

You will have all the fundamental tools to test any React component and have that coverage at 100%!

Have fun, and never stop learning!

The course project

In the course project, you will read the following material published by Kent C. Dodds: https://kentcdodds.com/blog/common-mistakes-with-react-testing-library

In this blog post, you will see common mistakes that people do when using RTL. You will try to find if I made any of the mistakes shown there and fix them! Even if you don't find any, it will be a great learning because you just learned what things you need to avoid when testing your React code.

21 Lessons

Introduction
10 mins
Introduction to TDD
free preview
5 mins
Introduction to RTL
free preview
9 mins
Create React App behind the scenes
Jest
5 mins
Understanding Jest
12 mins
Writing our first test
React Testing Library
13 mins
Rendering a component with RTL
8 mins
Selecting elements with getByText
8 mins
Selecting elements with getByRole
7 mins
queryBy search variant
7 mins
findBy search variant part 1
11 mins
findBy search variant part 2
7 mins
findBy search variant part 3
View more lessons +

About the instructor

David Armendariz

Hi! My name is David Armendáriz. I am from the beautiful country of Ecuador.

I studied mathematics at USFQ (Universidad San Francisco de Quito). However, …

Read more
This course is included in Arbington Premium
$15/month gets you access to every course. Start your 14 day trial today. ☝️

Class benefits

  • Certificate of Completion
  • 30 day satisfaction guarantee
  • 24/7 streaming access
  • Project included
  • Direct teacher access
  • 2h 36m of on-demand video
  • Have a coupon?
  • Checkout