Testing React Native Apps w/ Jest

Glauber Brack Castro
4 min readMay 17, 2022

Hi, there!

As a mobile developer, I was always concerned about app quality, and the number of unit/component tests in your app will boost its stability.

To make things easier, I built up a repository (check it out) with jest initial configs, so our playground is ready to go. However, read all of the instructions below to fully get what’s going on.

  1. Testing Library

Jest is installed by default in new React Native applications, but I prefer to utilize the React Native Testing Library (the name speaks for itself). We need to take the following steps to use this library:

yarn add @testing-library/react-native -D

As we are going to use Jest, we need to add one more dev dependency

yarn add @testing-library/jest-native -D

We’ll also do some navigational testing, so we’ll need to take some extra measures.

Create a setup.js file inside jest folder in root, so we’ll have something like the code bellow inside jest/setup.js

--

--