forked from enzymejs/enzyme
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d024934
commit e283e6d
Showing
19 changed files
with
237 additions
and
393 deletions.
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
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 |
---|---|---|
@@ -1,52 +1,9 @@ | ||
# Using Enzyme with Browserify | ||
|
||
If you are using a test runner that runs code in a browser-based environment, you may be using | ||
[browserify]() in order to bundle your React code. | ||
[browserify](http://browserify.org/) in order to bundle your React code. | ||
|
||
Browserify uses static analysis to create a dependency graph at build-time of your source code to | ||
build a bundle. Enzyme has a hand full of conditional `require()` calls in it in order to remain | ||
compatible with React 0.13 and React 0.14. | ||
|
||
Unfortunately, these conditional requires mean there is a bit of extra setup with bundlers like | ||
browserify. | ||
|
||
In your browserify configuration, you simply need to make sure that the following files are | ||
labeled as "external", which means they will be ignored: | ||
|
||
``` | ||
react/addons | ||
react/lib/ReactContext | ||
react/lib/ExecutionEnvironment | ||
``` | ||
|
||
Here is an example piece of configuration code marking these as external: | ||
|
||
```js | ||
const browserify = require('browserify'); | ||
|
||
const b = browserify(); | ||
|
||
// make sure to mark these as external! | ||
b.external('react/addons'); | ||
b.external('react/lib/ReactContext'); | ||
b.external('react/lib/ExecutionEnvironment'); | ||
|
||
// the rest of your browserify configuration | ||
``` | ||
|
||
|
||
## React 0.14 Compatibility | ||
|
||
If you are using React 0.14, the instructions above will be the same but with a different list of | ||
externals: | ||
|
||
``` | ||
react-dom | ||
react-dom/server | ||
react-addons-test-utils | ||
``` | ||
|
||
|
||
## Example Projects | ||
|
||
- [enzyme-example-karma](https://github.com/lelandrichardson/enzyme-example-karma) | ||
Prior to Enzyme 3.0 there were some issues with conditional requires that were used | ||
to maintain backwards compatibility with React versions. With Enzyme 3.0+, this | ||
should no longer be an issue. If it is, please file a GitHub issue or make a PR | ||
to this documentation with instructions on how to set it up. |
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.