Writing Tests for React Applications Using Jest and Enzyme
Learn about the testing frameworks Jest and Enzyme.
In this article, you will learn how to write tests for your React application using Jest and Enzyme. This is helpful if you want to write tests to catch edge cases, regressions, and have more confidence in shipping updates to your users.
This article uses yarn instead of npm. Yarn is an alternative package manager. The syntax for Yarn is slightly different compared to npm. You can use either package manager when following along.
yarn create-react-app my-app
npm create-react-app my-app
yarn add enzyme enzyme-adapter-react-16 --dev
npm install enzyme enzyme-adapter-react-16 --save-dev
yarn run test
npm run test