0.1.0 • Published 8 years ago
enzyme-react-16-adapter-setup v0.1.0
Enzyme React 16 adapter setup
Easy way to setup enzyme for React 16 in Jest.
Instalation
# Using yarn
yarn add --dev enzyme react-test-renderer enzyme-adapter-react-16 enzyme-react-16-adapter-setup
# Or using npm
npm install --dev enzyme react-test-renderer enzyme-adapter-react-16 enzyme-react-16-adapter-setupSetup
The idea of this package is to make a file in order to set up enzyme.
The easyest way is to use jest's setupFiles. Make sure your package.json includes the following:
{
// ...
"jest": {
// ...
"setupFiles": [
"raf/polyfill",
"enzyme-react-16-adapter-setup"
]
}
}Note: The example also adds requestAnimationFrame polyfill, if you are testing with jsdom, probabably you'll need it. In order to install it just do the following:
# Using yarn
yarn add --dev raf
# Or using npm
npm install --dev rafCreate React App
If you are using Create React App, you won't be able to use jest's setupFiles. You'll need to create the file src/setupTests.js with the following content:
// src/setupTests.js
import 'raf/polyfill';
import 'enzyme-react-16-adapter-setup';Note: You'll also have to add a requestAnimationFrame polyfill as jsdom doesn't provide one:
# Using yarn
yarn add --dev raf
# Or using npm
npm install --dev raf0.1.0
8 years ago