Skip to content

Commit 45d95bb

Browse files
committed
Convert kitchensink tests
1 parent 1608832 commit 45d95bb

File tree

1 file changed

+20
-65
lines changed

1 file changed

+20
-65
lines changed

tasks/e2e-kitchensink.sh

Lines changed: 20 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ cd "$(dirname "$0")"
1414

1515
# CLI, app, and test module temporary locations
1616
# http://unix.stackexchange.com/a/84980
17-
temp_cli_path=`mktemp -d 2>/dev/null || mktemp -d -t 'temp_cli_path'`
1817
temp_app_path=`mktemp -d 2>/dev/null || mktemp -d -t 'temp_app_path'`
1918
temp_module_path=`mktemp -d 2>/dev/null || mktemp -d -t 'temp_module_path'`
2019

@@ -23,7 +22,7 @@ function cleanup {
2322
ps -ef | grep 'react-scripts' | grep -v grep | awk '{print $2}' | xargs kill -9
2423
cd "$root_path"
2524
# TODO: fix "Device or resource busy" and remove ``|| $CI`
26-
rm -rf "$temp_cli_path" "$temp_app_path" "$temp_module_path" || $CI
25+
rm -rf "$temp_app_path" "$temp_module_path" || $CI
2726
}
2827

2928
# Error messages are redirected to stderr
@@ -40,30 +39,6 @@ function handle_exit {
4039
exit
4140
}
4241

43-
function create_react_app {
44-
node "$temp_cli_path"/node_modules/create-react-app/index.js "$@"
45-
}
46-
47-
function install_package {
48-
local pkg=$(basename $1)
49-
50-
# Clean target (for safety)
51-
rm -rf node_modules/$pkg/
52-
rm -rf node_modules/**/$pkg/
53-
54-
# Copy package into node_modules/ ignoring installed deps
55-
# rsync -a ${1%/} node_modules/ --exclude node_modules
56-
cp -R ${1%/} node_modules/
57-
rm -rf node_modules/$pkg/node_modules/
58-
59-
# Install `dependencies`
60-
cd node_modules/$pkg/
61-
yarn --production
62-
# Remove our packages to ensure side-by-side versions are used (which we link)
63-
rm -rf node_modules/{babel-preset-react-app,eslint-config-react-app,react-dev-utils,react-error-overlay,react-scripts}
64-
cd ../..
65-
}
66-
6742
# Check for the existence of one or more files.
6843
function exists {
6944
for f in $*; do
@@ -98,41 +73,33 @@ yarn build:prod
9873
cd ../..
9974

10075
# ******************************************************************************
101-
# First, pack react-scripts and create-react-app so we can use them.
76+
# First, publish the monorepo.
10277
# ******************************************************************************
10378

104-
# Pack CLI
105-
cd "$root_path"/packages/create-react-app
106-
cli_path=$PWD/`npm pack`
107-
108-
# Go to react-scripts
109-
cd "$root_path"/packages/react-scripts
110-
111-
# Save package.json because we're going to touch it
112-
cp package.json package.json.orig
79+
# Start local registry
80+
tmp_registry_log=`mktemp`
81+
nohup npx [email protected] &>$tmp_registry_log &
82+
# Wait for `verdaccio` to boot
83+
grep -q 'http address' <(tail -f $tmp_registry_log)
11384

114-
# Replace own dependencies (those in the `packages` dir) with the local paths
115-
# of those packages.
116-
node "$root_path"/tasks/replace-own-deps.js
85+
# Set registry to local registry
86+
npm set registry http://localhost:4873
87+
yarn config set registry http://localhost:4873
11788

118-
# Finally, pack react-scripts
119-
scripts_path="$root_path"/packages/react-scripts/`npm pack`
89+
# Login so we can publish packages
90+
npx [email protected] -u user -p password -e [email protected] -r http://localhost:4873 --quotes
12091

121-
# Restore package.json
122-
rm package.json
123-
mv package.json.orig package.json
92+
# Publish the monorepo
93+
git clean -f
94+
./tasks/release.sh --yes --force-publish=* --skip-git --cd-version=prerelease --exact --npm-tag=latest
12495

12596
# ******************************************************************************
126-
# Now that we have packed them, create a clean app folder and install them.
97+
# Now that we have published them, create a clean app folder and install them.
12798
# ******************************************************************************
12899

129-
# Install the CLI in a temporary location
130-
cd "$temp_cli_path"
131-
yarn add "$cli_path"
132-
133100
# Install the app in a temporary location
134101
cd $temp_app_path
135-
create_react_app --scripts-version="$scripts_path" --internal-testing-template="$root_path"/packages/react-scripts/fixtures/kitchensink test-kitchensink
102+
npx create-react-app --internal-testing-template="$root_path"/packages/react-scripts/fixtures/kitchensink test-kitchensink
136103

137104
# Install the test module
138105
cd "$temp_module_path"
@@ -146,14 +113,8 @@ yarn add test-integrity@^2.0.1
146113
# Enter the app directory
147114
cd "$temp_app_path/test-kitchensink"
148115

149-
# Link to our preset
150-
install_package "$root_path"/packages/babel-preset-react-app
151-
# Link to error overlay package because now it's a dependency
152-
# of react-dev-utils and not react-scripts
153-
install_package "$root_path"/packages/react-error-overlay
154-
155116
# Link to test module
156-
install_package "$temp_module_path/node_modules/test-integrity"
117+
npm link "$temp_module_path/node_modules/test-integrity"
157118

158119
# Test the build
159120
REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \
@@ -198,16 +159,10 @@ E2E_FILE=./build/index.html \
198159
# ******************************************************************************
199160

200161
# Eject...
201-
echo yes | npm run eject
202-
203-
# ...but still link to the local packages
204-
install_package "$root_path"/packages/babel-preset-react-app
205-
install_package "$root_path"/packages/eslint-config-react-app
206-
install_package "$root_path"/packages/react-error-overlay
207-
install_package "$root_path"/packages/react-dev-utils
162+
echo yes | yarn eject
208163

209164
# Link to test module
210-
install_package "$temp_module_path/node_modules/test-integrity"
165+
npm link "$temp_module_path/node_modules/test-integrity"
211166

212167
# Test the build
213168
REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \

0 commit comments

Comments
 (0)