Chapter 3: How to Test React Components Using Jest

by Jack Franklin

In this tutorial, we'll take a look at using Jest – a testing framework maintained by Facebook – to test our ReactJS components. We'll look at how we can use Jest first on plain JavaScript functions, before looking at some of the features it provides out of the box specifically aimed at making testing React apps easier. It's worth noting that Jest isn't aimed specifically at React: you can use it to test any JavaScript applications. However, a couple of the features it provides come in really handy for testing user interfaces, which is why it's a great fit with React.

Sample Application

Before we can test anything, we need an application to test! Staying true to web development ...

Get React: Tools & Resources 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.