12

Unit Testing with Jest and React Testing Library

In this chapter, we learn how to use Jest and React Testing Library, two popular automated testing tools that can be used together in React applications. We will create tests on the checklist component we created in Chapter 11, Reusable Components.

We will start by focusing on Jest and using it to test simple functions, learning about Jest’s common matcher functions for writing expectations, and how to execute tests to check whether they pass.

We will then move on to learning about component testing using React Testing Library. We’ll understand the different query types and variants and how they help us create robust tests.

After that, we will learn the most accurate way to simulate user interactions ...

Get Learn React with TypeScript - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.