We suggest using yarn for installations.
yarn add jest-enzyme --dev
But npm works too!
$ npm install jest-enzyme --save-dev
The simplest setup is to use jest's setupTestFrameworkScriptFile
config.
On older versions of Jest, you'll also need to tell jest to unmock
react
,enzyme
, andjest-enzyme
.
Make sure your package.json
includes the following:
"jest": {
"setupTestFrameworkScriptFile": "./node_modules/jest-enzyme/lib/index.js",
// old versions of jest set the unmocks
"unmockedModulePathPatterns": [
"react",
"enzyme",
"jasmine-enzyme"
]
},