Chapter 21. Testing with Jest and the React Testing Library

In the next two chapters, you will implement some tests in Code Café. Though all the details of testing a React app could fill a book of their own, these chapters will give you some initial experience to build on.

In this chapter, you will use libraries included with Create React App to write unit and integration tests.

Create React App automatically includes four libraries for testing your application. The first is Jest, a JavaScript testing framework that includes all the features you need to write and run tests, including a test runner, a mocking library, and an assertion library. Jest creates a fake DOM (called jsdom) to simulate the browser environment without rendering HTML to ...

Get React Programming: The Big Nerd Ranch Guide 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.