Commit 4add16dc authored by Ryan Sullivan's avatar Ryan Sullivan Committed by Dan Abramov
Browse files

Add documentation for Enzyme 3 integration (#3286)

This resolves #3272.
parent 1fa16ace
3 merge requests!12191Lim.Pisey.168:/Identified - We are currently investigating reports of missing build logs. The issue has been identified and a resolution is in progress. We will provide a further update when available.Mar 21, 09:02 UTC,!12853brikk,!5717Automatically extract project file structure from build bundle file
Showing with 15 additions and 3 deletions
+15 -3
...@@ -1262,16 +1262,28 @@ When you encounter bugs caused by changing components, you will gain a deeper in ...@@ -1262,16 +1262,28 @@ When you encounter bugs caused by changing components, you will gain a deeper in
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: 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:
```sh ```sh
npm install --save enzyme react-test-renderer npm install --save enzyme enzyme-adapter-react-16 react-test-renderer
``` ```
Alternatively you may use `yarn`: Alternatively you may use `yarn`:
```sh ```sh
yarn add enzyme react-test-renderer yarn add enzyme enzyme-adapter-react-16 react-test-renderer
``` ```
You can write a smoke test with it too: 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.)
The adapter will also need to be configured in your [global setup file](#initializing-test-environment):
#### `src/setupTests.js`
```js
import { configure } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
configure({ adapter: new Adapter() });
```
Now you can write a smoke test with it:
```js ```js
import React from 'react'; import React from 'react';
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment