-
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
Showing
7 changed files
with
47 additions
and
33 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 |
---|---|---|
@@ -1,22 +1,29 @@ | ||
#!/bin/bash | ||
set -ev | ||
|
||
echo "installing React $REACT_VERSION" | ||
REACT_VERSION_NORMALIZED=$REACT_VERSION | ||
if [ "${REACT_VERSION:0:2}" = "0." ]; then | ||
REACT_VERSION_NORMALIZED=${REACT_VERSION:2} | ||
fi | ||
|
||
echo "installing React $REACT_VERSION ($REACT_VERSION_NORMALIZED)" | ||
echo "Travis Node Version $TRAVIS_NODE_VERSION" | ||
node --version | ||
npm --version | ||
|
||
npm uninstall --no-save react react-dom react-addons-test-utils react-test-renderer | ||
rm -rf node_modules/.bin/npm node_modules/.bin/npm.cmd node_modules/react node_modules/react-dom node_modules/react-addons-test-utils node_modules/react-test-renderer | ||
npm uninstall --no-save react react-dom react-addons-test-utils react-test-renderer enzyme-adapter-react-16 | ||
rm -rf node_modules/.bin/npm node_modules/.bin/npm.cmd node_modules/react node_modules/react-dom node_modules/react-addons-test-utils node_modules/react-test-renderer node_modules/enzyme-adapter-react-16 | ||
npm prune | ||
|
||
npm install | ||
|
||
# Conditionally install dependencies per https://github.com/airbnb/enzyme#installation | ||
if [ "${REACT_VERSION:0:2}" = "0." ]; then | ||
npm install --no-save react@$REACT_VERSION react-dom@$REACT_VERSION react-addons-test-utils@$REACT_VERSION | ||
else | ||
npm install --no-save react@$REACT_VERSION react-dom@$REACT_VERSION react-test-renderer@$REACT_VERSION | ||
if [ "${REACT_VERSION_NORMALIZED}" = "13" ]; then | ||
npm install --no-save react@$REACT_VERSION enzyme-adapter-react-$REACT_VERSION_NORMALIZED | ||
elif [ "${REACT_VERSION_NORMALIZED}" = "14" ]; then | ||
npm install --no-save react@$REACT_VERSION react-dom@$REACT_VERSION react-addons-test-utils@$REACT_VERSION enzyme-adapter-react-$REACT_VERSION_NORMALIZED | ||
elif [ "${REACT_VERSION_NORMALIZED}" = "15" ]; then | ||
npm install --no-save react@$REACT_VERSION react-dom@$REACT_VERSION react-test-renderer@$REACT_VERSION enzyme-adapter-react-$REACT_VERSION_NORMALIZED | ||
else # React 16+ | ||
npm install --no-save react@$REACT_VERSION react-dom@$REACT_VERSION enzyme-adapter-react-$REACT_VERSION_NORMALIZED | ||
fi | ||
|
||
npm ls --depth=0 |
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,11 @@ | ||
/* eslint-disable global-require, import/no-extraneous-dependencies, import/no-unresolved */ | ||
const configure = require('enzyme').configure; | ||
const reactVersion = require('react').version; | ||
|
||
const [majorReactVersion, minorReactVersion] = reactVersion.split('.'); | ||
const adapterVersion = (majorReactVersion !== '0') ? majorReactVersion : minorReactVersion; | ||
|
||
// eslint-disable-next-line import/no-dynamic-require | ||
const Adapter = require(`enzyme-adapter-react-${adapterVersion}`); | ||
|
||
configure({ adapter: new Adapter() }); |