Skip to content
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

Stop using npm link in tests #3345

Merged
merged 28 commits into from
Oct 30, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ image: Visual Studio 2017

environment:
matrix:
- nodejs_version: 7
- nodejs_version: 8
test_suite: "simple"
- nodejs_version: 7
- nodejs_version: 8
test_suite: "installs"
- nodejs_version: 7
- nodejs_version: 8
test_suite: "kitchensink"
- nodejs_version: 6
test_suite: "simple"
Expand Down
55 changes: 41 additions & 14 deletions tasks/e2e-kitchensink.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,31 @@ function create_react_app {
node "$temp_cli_path"/node_modules/create-react-app/index.js "$@"
}

function install_package {
local pkg=$(basename $1)

# Clean target (for safety)
rm -rf node_modules/$pkg/
rm -rf node_modules/**/$pkg/

# Copy package into node_modules/ ignoring installed deps
# rsync -a ${1%/} node_modules/ --exclude node_modules
cp -R ${1%/} node_modules/
rm -rf node_modules/$pkg/node_modules/

# Install `dependencies`
cd node_modules/$pkg/
if [ "$USE_YARN" = "yes" ]
then
yarn install --production
else
npm install --only=production
fi
# Remove our packages to ensure side-by-side versions are used (which we link)
rm -rf node_modules/{babel-preset-react-app,eslint-config-react-app,react-dev-utils,react-error-overlay,react-scripts}
cd ../..
}

# Check for the existence of one or more files.
function exists {
for f in $*; do
Expand Down Expand Up @@ -162,13 +187,13 @@ npm install test-integrity@^2.0.1
cd "$temp_app_path/test-kitchensink"

# Link to our preset
npm link "$root_path"/packages/babel-preset-react-app
install_package "$root_path"/packages/babel-preset-react-app
# Link to error overlay package because now it's a dependency
# of react-dev-utils and not react-scripts
npm link "$root_path"/packages/react-error-overlay
install_package "$root_path"/packages/react-error-overlay

# Link to test module
npm link "$temp_module_path/node_modules/test-integrity"
install_package "$temp_module_path/node_modules/test-integrity"

# Test the build
REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \
Expand Down Expand Up @@ -219,23 +244,25 @@ E2E_FILE=./build/index.html \
# Finally, let's check that everything still works after ejecting.
# ******************************************************************************

# Unlink our preset
npm unlink "$root_path"/packages/babel-preset-react-app
# Unlink error overlay
npm unlink "$root_path"/packages/react-error-overlay

# Eject...
echo yes | npm run eject

# Ensure Yarn is ran after eject; at the time of this commit, we don't run Yarn
# after ejecting. Soon, we may only skip Yarn on Windows. Let's try to remove
# this in the near future.
if hash yarnpkg 2>/dev/null
then
yarn install --check-files
fi

# ...but still link to the local packages
npm link "$root_path"/packages/babel-preset-react-app
npm link "$root_path"/packages/eslint-config-react-app
npm link "$root_path"/packages/react-error-overlay
npm link "$root_path"/packages/react-dev-utils
npm link "$root_path"/packages/react-scripts
install_package "$root_path"/packages/babel-preset-react-app
install_package "$root_path"/packages/eslint-config-react-app
install_package "$root_path"/packages/react-error-overlay
install_package "$root_path"/packages/react-dev-utils

# Link to test module
npm link "$temp_module_path/node_modules/test-integrity"
install_package "$temp_module_path/node_modules/test-integrity"

# Test the build
REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \
Expand Down
40 changes: 36 additions & 4 deletions tasks/e2e-simple.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,31 @@ function create_react_app {
node "$temp_cli_path"/node_modules/create-react-app/index.js "$@"
}

function install_package {
local pkg=$(basename $1)

# Clean target (for safety)
rm -rf node_modules/$pkg/
rm -rf node_modules/**/$pkg/

# Copy package into node_modules/ ignoring installed deps
# rsync -a ${1%/} node_modules/ --exclude node_modules
cp -R ${1%/} node_modules/
rm -rf node_modules/$pkg/node_modules/

# Install `dependencies`
cd node_modules/$pkg/
if [ "$USE_YARN" = "yes" ]
then
yarn install --production
else
npm install --only=production
fi
# Remove our packages to ensure side-by-side versions are used (which we link)
rm -rf node_modules/{babel-preset-react-app,eslint-config-react-app,react-dev-utils,react-error-overlay,react-scripts}
cd ../..
}

# Check for the existence of one or more files.
function exists {
for f in $*; do
Expand Down Expand Up @@ -306,11 +331,18 @@ verify_module_scope
# Eject...
echo yes | npm run eject

# Ensure Yarn is ran after eject; at the time of this commit, we don't run Yarn
# after ejecting. Soon, we may only skip Yarn on Windows. Let's try to remove
# this in the near future.
if hash yarnpkg 2>/dev/null
then
yarnpkg install --check-files
fi

# ...but still link to the local packages
npm link "$root_path"/packages/babel-preset-react-app
npm link "$root_path"/packages/eslint-config-react-app
npm link "$root_path"/packages/react-dev-utils
npm link "$root_path"/packages/react-scripts
install_package "$root_path"/packages/babel-preset-react-app
install_package "$root_path"/packages/eslint-config-react-app
install_package "$root_path"/packages/react-dev-utils

# Test the build
npm run build
Expand Down