-
-
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.
Rip out sinon, mocha, and jsdom dependencies
This refactor addresses several issues regarding enzyme working in a variety of environments, and the library just generally not making any assumptions about the environment that tests will be run in. For the most part, this amounts to: - remove direct dependency on jsdom - remove direct dependency on sinon - remove assumed dependency on mocha In addition to this, I would like to create several "example" projects that are some basic boilerplate to getting enzyme up and running with some combination of bundler/test runner/etc. These projects can end up being devDependencies to enzyme and we can run their tests as part of our tests, which will ensure that changes we make to enzyme will be compatible with environments we claim to support moving forward. Lastly, as a matter of organization, tests have been moved from `src/__tests__/*` to `tests/*`. Left to do for this to be mergable is: [ ] Add a "guides" section in the docs explaining how to use enzyme in different environments [ ] Add example projects as dev dependencies, include their tests in enzyme's test script
- Loading branch information
1 parent
ec1c559
commit 219e50a
Showing
28 changed files
with
542 additions
and
303 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,67 @@ | ||
language: node_js | ||
node_js: | ||
- "5.1" | ||
- "5.0" | ||
- "4.2" | ||
- "4.1" | ||
- "4.0" | ||
- "iojs-v3.3" | ||
- "5" | ||
- "4" | ||
- "iojs" | ||
- "0.12" | ||
- "0.11" | ||
- "0.10" | ||
before_install: | ||
- 'if [ "${TRAVIS_NODE_VERSION}" != "0.9" ]; then case "$(npm --version)" in 1.*) npm install -g npm@1.4.28 ;; 2.*) npm install -g npm@2 ;; esac ; fi' | ||
- 'if [ "${TRAVIS_NODE_VERSION}" != "0.6" ] && [ "${TRAVIS_NODE_VERSION}" != "0.9" ]; then npm install -g npm; fi' | ||
before_script: "sh install-relevant-react.sh" | ||
script: | ||
- 'if [ "${TRAVIS_NODE_VERSION}" = "4.2" ]; then npm run lint && npm run travis ; elif [ "${TRAVIS_NODE_VERSION}" = "0.12" ]; then npm run travis ; else npm test ; fi' | ||
- 'if [ -z "$REACT" ] && [ "${TRAVIS_NODE_VERSION}" = "4" ]; then npm run test:env -- "${EXAMPLE}" ; elif [ -z "$REACT" ]; then echo "Test Skipped" ; elif [ "${TRAVIS_NODE_VERSION}" = "4" ]; then npm run lint && npm run travis ; elif [ "${TRAVIS_NODE_VERSION}" = "0.12" ]; then npm run travis ; else npm test ; fi' | ||
after_script: | ||
- 'if [ "${TRAVIS_NODE_VERSION}" = "4.2" ] || [ "${TRAVIS_NODE_VERSION}" = "0.12" ]; then cat ./coverage/lcov.info | ./node_modules/.bin/coveralls ; fi' | ||
- 'if [ "${TRAVIS_NODE_VERSION}" = "4" ] || [ "${TRAVIS_NODE_VERSION}" = "0.12" ]; then cat ./coverage/lcov.info | ./node_modules/.bin/coveralls ; fi' | ||
env: | ||
- REACT=0.13 | ||
- REACT=0.14 | ||
- EXAMPLE=mocha | ||
- EXAMPLE=karma | ||
- EXAMPLE=react-native | ||
- EXAMPLE=karma-webpack | ||
- EXAMPLE=jest | ||
sudo: false | ||
matrix: | ||
fast_finish: true | ||
allow_failures: | ||
- node_js: "5.0" | ||
- node_js: "4.1" | ||
- node_js: "4.0" | ||
- node_js: "0.11" | ||
exclude: | ||
- node_js: "4" | ||
env: EXAMPLE=mocha | ||
- node_js: "4" | ||
env: EXAMPLE=karma | ||
- node_js: "4" | ||
env: EXAMPLE=react-native | ||
- node_js: "4" | ||
env: EXAMPLE=karma-webpack | ||
- node_js: "4" | ||
env: EXAMPLE=jest | ||
- node_js: "iojs" | ||
env: EXAMPLE=mocha | ||
- node_js: "iojs" | ||
env: EXAMPLE=karma | ||
- node_js: "iojs" | ||
env: EXAMPLE=react-native | ||
- node_js: "iojs" | ||
env: EXAMPLE=karma-webpack | ||
- node_js: "iojs" | ||
env: EXAMPLE=jest | ||
- node_js: "0.12" | ||
env: EXAMPLE=mocha | ||
- node_js: "0.12" | ||
env: EXAMPLE=karma | ||
- node_js: "0.12" | ||
env: EXAMPLE=react-native | ||
- node_js: "0.12" | ||
env: EXAMPLE=karma-webpack | ||
- node_js: "0.12" | ||
env: EXAMPLE=jest | ||
- node_js: "0.10" | ||
env: EXAMPLE=mocha | ||
- node_js: "0.10" | ||
env: EXAMPLE=karma | ||
- node_js: "0.10" | ||
env: EXAMPLE=react-native | ||
- node_js: "0.10" | ||
env: EXAMPLE=karma-webpack | ||
- node_js: "0.10" | ||
env: EXAMPLE=jest |
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Enzyme Guides | ||
|
||
- [*Using Enzyme with Browserify*](guides/browserify.md) | ||
- [*Using Enzyme with WebPack*](guides/webpack.md) | ||
- [*Using Enzyme with JSDOM*](guides/jsdom.md) | ||
- [*Using Enzyme with React Native*](guides/react-native.md) | ||
- [*Using Enzyme with Jest*](guides/jest.md) | ||
- [*Using Enzyme with Karma*](guides/karma.md) | ||
- [*Using Enzyme with Mocha*](guides/mocha.md) |
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,50 @@ | ||
# 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 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 two files are | ||
labeled as "external", which means they will be ignored: | ||
|
||
``` | ||
react/lib/ReactContext | ||
react/lib/ExecutionEnvironment | ||
``` | ||
|
||
Here is an example piece of configuration code marking these as external: | ||
|
||
```js | ||
var browserify = require('browserify'); | ||
|
||
var b = browserify(); | ||
|
||
// make sure to mark these as external! | ||
b.external('react/lib/ReactContext'); | ||
b.external('react/lib/ExecutionEnvironment'); | ||
|
||
// the rest of your browserify configuration | ||
``` | ||
|
||
|
||
## React 0.13 Compatibility | ||
|
||
If you are using React 0.13, 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) |
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,32 @@ | ||
# Using Jest with Enzyme | ||
|
||
If you are using Jest with enzyme and using Jest's "automocking" feature, you will need to mark | ||
several modules to be unmocked in your `package.json`: | ||
|
||
```js | ||
/* package.json */ | ||
|
||
"jest": { | ||
"scriptPreprocessor": "<rootDir>/node_modules/babel-jest", | ||
"unmockedModulePathPatterns": [ | ||
"react", | ||
"react-dom", | ||
"react-addons-test-utils", | ||
"fbjs", | ||
"enzyme", | ||
"cheerio", | ||
"htmlparser2", | ||
"underscore", | ||
"lodash", | ||
"domhandler", | ||
"object.assign", | ||
"define-properties", | ||
"function-bind", | ||
"object-keys" | ||
] | ||
} | ||
``` | ||
|
||
## Example Projects | ||
|
||
- [enzyme-example-ject](https://github.com/lelandrichardson/enzyme-example-jest) |
Oops, something went wrong.