Skip to content

How to setup and use Jest and Enzyme to test a React application created with Create React App (CRA)

Notifications You must be signed in to change notification settings

subinchaliyath/Unit-Testing-React

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Getting Started with Unit Test

How to setup and use Jest and Enzyme to test a React application created with Create React App (CRA)

Installation

npm install --save-dev enzyme enzyme-adapter-react-16

Step 1

Create a setupTests.js file at ./src/setupTests.js:

import { configure } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
configure({ adapter: new Adapter() });

Terms

Shallow

Renders only the single component, not including its children. This is useful to isolate the component for pure unit testing.

Jest will look for tests in any of the following places:

Files with .js suffix in tests folders. Files with .test.js suffix. Files with .spec.js suffix.

About

How to setup and use Jest and Enzyme to test a React application created with Create React App (CRA)

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published