-
-
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.
Merge pull request #464 from tamird/jspm-webpack
docs: add systemjs guide
- Loading branch information
Showing
2 changed files
with
75 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# Using Enzyme with SystemJS | ||
|
||
If you are using a test runner that runs code in a browser-based environment, | ||
you may be using [SystemJS]() in order to bundle your React code. | ||
|
||
SystemJS 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 SystemJS. | ||
|
||
In your SystemJS 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: | ||
|
||
```json | ||
/* package.json */ | ||
{ | ||
"jspm": { | ||
"overrides": { | ||
"npm:enzyme@2.3.0": { | ||
"map": { | ||
"react/addons": "@empty", | ||
"react/lib/ExecutionEnvironment": "@empty", | ||
"react/lib/ReactContext": "@empty" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
``` | ||
|
||
|
||
## 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 | ||
``` | ||
|
||
## React 15 Compatability | ||
|
||
If you are using React 15, your config should include these externals: | ||
|
||
```json | ||
/* package.json */ | ||
{ | ||
"jspm": { | ||
"overrides": { | ||
"npm:enzyme@2.3.0": { | ||
"map": { | ||
"react/addons": "@empty", | ||
"react/lib/ExecutionEnvironment": "@empty", | ||
"react/lib/ReactContext": "@empty" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
``` |