-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Docs] Add docs reflecting v3 #1121
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
e283e6d
Starting point
lelandrichardson 39c4c84
More docs
lelandrichardson 10983cb
publishing
lelandrichardson 8a5932a
more migration docs
lelandrichardson 94ec3ce
more docs updates
lelandrichardson cd8a2c7
lowercase enzyme
lelandrichardson 9a011af
remove outdated future docs
lelandrichardson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,13 +7,70 @@ Enzyme | |
[![Discord Channel](https://img.shields.io/badge/discord-testing@reactiflux-738bd7.svg?style=flat-square)](https://discord.gg/0ZcbPKXt5bY8vNTA) | ||
|
||
|
||
|
||
Enzyme is a JavaScript Testing utility for React that makes it easier to assert, manipulate, | ||
and traverse your React Components' output. | ||
|
||
Enzyme's API is meant to be intuitive and flexible by mimicking jQuery's API for DOM manipulation | ||
and traversal. | ||
|
||
Upgrading from Enzyme 2.x or React < 16 | ||
=========== | ||
|
||
Are you here to check whether or not Enzyme is compatible with React 16? Are you currently using | ||
Enzyme 2.x? Great! Check out our [migration guide](/docs/guides/migration-from-2-to-3.md) for help | ||
moving on to Enzyme v3 where React 16 is supported. | ||
|
||
### [Installation](/docs/installation/README.md) | ||
|
||
To get started with enzyme, you can simply install it via npm. You will need to install enzyme | ||
along with an Adapter corresponding to the version of react (or other UI Component library) you | ||
are using. For instance, if you are using enzyme with React 16, you can run: | ||
|
||
```bash | ||
npm i --save-dev enzyme enzyme-adapter-react-16 | ||
``` | ||
|
||
Each adapter may have additional peer dependencies which you will need to install as well. For instance, | ||
`enzyme-adapter-react-16` has peer dependencies on `react`, `react-dom`, and `react-test-renderer`. | ||
|
||
At the moment, Enzyme has adapters that provide compatibility with `React 16.x`, `React 15.x`, | ||
`React 0.14.x` and `React 0.13.x`. | ||
|
||
The following adapters are officially provided by enzyme, and have the following compatibility with | ||
React: | ||
|
||
| Enzyme Adapter Package | React semver compatibility | | ||
| --- | --- | | ||
| `enzyme-adapter-react-16` | `^16.0.0` | | ||
| `enzyme-adapter-react-15` | `^15.5.0` | | ||
| `enzyme-adapter-react-15.4` | `15.0.0-0 - 15.4.x` | | ||
| `enzyme-adapter-react-14` | `^0.14.0` | | ||
| `enzyme-adapter-react-13` | `^0.13.0` | | ||
|
||
Finally, you need to configure enzyme to use the adapter you want it to use. To do this, you can use | ||
the top level `configure(...)` API. | ||
|
||
```js | ||
import Enzyme from 'enzyme'; | ||
import Adapter from 'enzyme-adapter-react-16'; | ||
|
||
Enzyme.configure({ adapter: new Adapter() }); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it seems kind of weird that adapters need to be constructed; could |
||
``` | ||
|
||
3rd Party Adapters | ||
============= | ||
|
||
It is possible for the community to create additional (non-official) adapters that will make enzyme | ||
work with other libraries. If you have made one and it's not included in the list below, feel free | ||
to make a PR to this README and add a link to it! The known 3rd party adapters are: | ||
|
||
| Adapter Package | For Library | Status | | ||
| --- | --- | --- | | ||
| [`preact-enzyme-adapter`](https://github.com/aweary/preact-enzyme-adapater) | [`preact`](https://github.com/developit/preact) | (work in progress) | | ||
|
||
Running Enzyme Tests | ||
=========== | ||
|
||
Enzyme is unopinionated regarding which test runner or assertion library you use, and should be | ||
compatible with all major test runners and assertion libraries out there. The documentation and | ||
examples for enzyme use [mocha](https://mochajs.org/) and [chai](http://chaijs.com/), but you | ||
|
@@ -49,32 +106,6 @@ testing your React components, you can consider using: | |
|
||
[Using Enzyme with Tape and AVA](/docs/guides/tape-ava.md) | ||
|
||
### [Installation](/docs/installation/README.md) | ||
|
||
To get started with enzyme, you can simply install it with npm: | ||
|
||
```bash | ||
npm i --save-dev enzyme | ||
``` | ||
|
||
Enzyme is currently compatible with `React 15.x`, `React 0.14.x` and `React 0.13.x`. In order to | ||
achieve this compatibility, some dependencies cannot be explicitly listed in our `package.json`. | ||
|
||
If you are using `React 0.14` or `React <15.5`, in addition to `enzyme`, you will have to ensure that | ||
you also have the following npm modules installed if they were not already: | ||
|
||
```bash | ||
npm i --save-dev react-addons-test-utils react-dom | ||
``` | ||
|
||
If you are using `React >=15.5`, in addition to `enzyme`, you will have to ensure that you also have | ||
the following npm modules installed if they were not already: | ||
|
||
```bash | ||
npm i --save-dev react-test-renderer react-dom | ||
``` | ||
|
||
|
||
Basic Usage | ||
=========== | ||
|
||
|
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
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we make
import { configure } from 'enzyme'
also work, even if it's not in the docs?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ljharb it does work