React Jest configuration with jsx and js | React testing library jest dom


React jest configuration with jsx and js | React testing library jest dom


Step 1 : Create React Project Using create-react-app

npx create-react-app jest-testing-library


Step 2 : Install React testing library dependencies

npm install --save-dev @testing-library/react @testing-library/jest-dom

OR

yarn add --dev @testing-library/react @testing-library/jest-dom


Step 3 : Install Jest dependecies

npm install --save-dev jest jest-environment-jsdom

OR

yarn add --dev jest jest-environment-jsdom



Step 4 : Configure Jest

Create a file named jest.config.js in the root folder and add the following code configuration.



Step 5 : Writing tests

Create One Component

Example.jsx


Create Test File

Example.test.jsx


Output

React jest configuration with jsx and js | React testing library jest dom