Search⌘ K
AI Features

Installing & Running Jest

Explore how to install and set up Jest, run tests in different modes including silent, verbose, and watch, and optimize test runs by targeting changed files or commits. Understand key command line options to manage testing workflow effectively.

Installation

First, we need to make sure we have Jest installed. Jest is a regular third-party package that is installable via the npm and Yarn registries.

If we are working inside a Create React App project, Jest is already installed as the test runner. Both were created by and are maintained by Meta. Yarn was also created by this team. CRA also ships with React Testing Library.

At the time of writing this, CRA ships with Jest as a production dependency. There are differences in opinion within the React community on this, but because it is inherently not used in production, we suggest moving ...