-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds documentation for mount tracking
- Loading branch information
Showing
4 changed files
with
65 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# Automatic mount tracking | ||
|
||
If you are wanting to use enzyme in a large-scale application, you may want to automate | ||
calls to `unmount()` via a lifecycle hook in your test environment, rather than at the | ||
individual test level. Enzyme allows for this as part of its configuration: | ||
|
||
ES6: | ||
```js | ||
// setup file | ||
import { configure } from 'enzyme'; | ||
import Adapter from 'enzyme-adapter-react-16'; | ||
|
||
configure({ | ||
adapter: new Adapter(), | ||
enableMountTracking: true, | ||
}); | ||
``` | ||
|
||
```js | ||
// test file | ||
import { shallow, mount } from 'enzyme'; | ||
|
||
const wrapper = mount(<Foo />); | ||
``` | ||
|
||
```js | ||
// test file (in a lifecycle hook) | ||
import { unmountAllWrappers } from 'enzyme'; | ||
|
||
unmountAllWrappers(); | ||
``` | ||
|
||
ES5: | ||
<!-- eslint no-var: 0 --> | ||
```js | ||
// setup file | ||
var enzyme = require('enzyme'); | ||
var Adapter = require('enzyme-adapter-react-16'); | ||
|
||
enzyme.configure({ | ||
adapter: new Adapter(), | ||
enableMountTracking: true, | ||
}); | ||
``` | ||
|
||
<!-- eslint no-var: 0 --> | ||
```js | ||
// test file | ||
var enzyme = require('enzyme'); | ||
|
||
var wrapper = enzyme.mount(<Foo />); | ||
``` | ||
|
||
<!-- eslint no-var: 0 --> | ||
```js | ||
// test file (in a lifecycle hook) | ||
var enzyme = require('enzyme'); | ||
|
||
enzyme.unmountAllWrappers(); | ||
``` |