Udemy
    •  
    •  
    •  
    •  
    •  
    •  
    •  
    •  
Turn what you know into an opportunity and reach millions around the world.
Learn More
Your cart is empty.
Keep shopping
Testing React apps with React Testing Library (RTL)
Highest Rated
Rating: 4.6 out of 5(1,503 ratings)
5,865 students

Testing React apps with React Testing Library (RTL)

Learn how to test React components with React Testing Library, the recommended library from Facebook for testing.
Last updated 2/2021
English

What you'll learn

  • The principles of Test Driven Development (TDD)
  • Know what React Testing Library is and its differences with Enzyme
  • Understand how Jest works with React Testing Library
  • Query elements with getBy, queryBy, findBy, getAllBy, queryAllBy, findAllBy
  • Simulate user interaction with the fireEvent and userEvent API
  • Learn about coverage and debugging
  • How to mock third party libraries like Axios
  • How to use Typescript with a React app

Course content

8 sections25 lectures2h 37m total length
  • Introduction to TDD9:23
  • Introduction to RTL4:01

    React Testing Library centers tests on end-user interactions, not component internals, guiding maintainable tests that survive refactors; compare RTL with Enzyme and clarify Jest's role.

Requirements

  • Be famliarized with React components

Description

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!

Who this course is for:

  • Web developers
  • Full stack developers
  • Developers interested in Test Driven Development
  • Front-end developers