Skip to content

Commit aa79641

Browse files
ryansullygaearon
authored andcommittedOct 28, 2017
Add documentation for Enzyme 3 integration (facebook#3286)
This resolves facebook#3272.
1 parent 611df8f commit aa79641

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed
 

‎template/README.md

+15-3
Original file line numberDiff line numberDiff line change
@@ -1262,16 +1262,28 @@ When you encounter bugs caused by changing components, you will gain a deeper in
12621262
If you’d like to test components in isolation from the child components they render, we recommend using [`shallow()` rendering API](http://airbnb.io/enzyme/docs/api/shallow.html) from [Enzyme](http://airbnb.io/enzyme/). To install it, run:
12631263

12641264
```sh
1265-
npm install --save enzyme react-test-renderer
1265+
npm install --save enzyme enzyme-adapter-react-16 react-test-renderer
12661266
```
12671267

12681268
Alternatively you may use `yarn`:
12691269

12701270
```sh
1271-
yarn add enzyme react-test-renderer
1271+
yarn add enzyme enzyme-adapter-react-16 react-test-renderer
12721272
```
12731273

1274-
You can write a smoke test with it too:
1274+
As of Enzyme 3, you will need to install Enzyme along with an Adapter corresponding to the version of React you are using. (The examples above use the adapter for React 16.)
1275+
1276+
The adapter will also need to be configured in your [global setup file](#initializing-test-environment):
1277+
1278+
#### `src/setupTests.js`
1279+
```js
1280+
import { configure } from 'enzyme';
1281+
import Adapter from 'enzyme-adapter-react-16';
1282+
1283+
configure({ adapter: new Adapter() });
1284+
```
1285+
1286+
Now you can write a smoke test with it:
12751287

12761288
```js
12771289
import React from 'react';

0 commit comments

Comments
 (0)