Skip to content

Commit d29d41b

Browse files
authored
Try to use Yarn in more E2E scripts (facebook#3739)
* Try to use Yarn in more E2E scripts * Keep using npm pack * Maybe this will fix Windows? * Try this
1 parent dcd8ea6 commit d29d41b

File tree

3 files changed

+42
-132
lines changed

3 files changed

+42
-132
lines changed

tasks/e2e-installs.sh

+6-31
Original file line numberDiff line numberDiff line change
@@ -72,42 +72,17 @@ set -x
7272
cd ..
7373
root_path=$PWD
7474

75-
# Clear cache to avoid issues with incorrect packages being used
76-
if hash yarnpkg 2>/dev/null
77-
then
78-
# AppVeyor uses an old version of yarn.
79-
# Once updated to 0.24.3 or above, the workaround can be removed
80-
# and replaced with `yarnpkg cache clean`
81-
# Issues:
82-
# https://github.com/yarnpkg/yarn/issues/2591
83-
# https://github.com/appveyor/ci/issues/1576
84-
# https://github.com/facebookincubator/create-react-app/pull/2400
85-
# When removing workaround, you may run into
86-
# https://github.com/facebookincubator/create-react-app/issues/2030
87-
case "$(uname -s)" in
88-
*CYGWIN*|MSYS*|MINGW*) yarn=yarn.cmd;;
89-
*) yarn=yarnpkg;;
90-
esac
91-
$yarn cache clean
92-
fi
93-
94-
if hash npm 2>/dev/null
95-
then
96-
npm i -g npm@latest
97-
npm cache clean || npm cache verify
98-
fi
99-
10075
# Prevent bootstrap, we only want top-level dependencies
10176
cp package.json package.json.bak
10277
grep -v "postinstall" package.json > temp && mv temp package.json
103-
npm install
78+
yarn
10479
mv package.json.bak package.json
10580

10681
# We removed the postinstall, so do it manually
10782
node bootstrap.js
10883

10984
cd packages/react-error-overlay/
110-
npm run build:prod
85+
yarn run build:prod
11186
cd ../..
11287

11388
# ******************************************************************************
@@ -120,7 +95,7 @@ cli_path=$PWD/`npm pack`
12095

12196
# Install the CLI in a temporary location
12297
cd "$temp_cli_path"
123-
npm install "$cli_path"
98+
yarn add "$cli_path"
12499

125100
# ******************************************************************************
126101
# Test --scripts-version with a version number
@@ -222,20 +197,20 @@ cd test-app-nested-paths-t1
222197
mkdir -p test-app-nested-paths-t1/aa/bb/cc/dd
223198
create_react_app test-app-nested-paths-t1/aa/bb/cc/dd
224199
cd test-app-nested-paths-t1/aa/bb/cc/dd
225-
npm start -- --smoke-test
200+
yarn start --smoke-test
226201

227202
# Testing a path that does not exist
228203
cd "$temp_app_path"
229204
create_react_app test-app-nested-paths-t2/aa/bb/cc/dd
230205
cd test-app-nested-paths-t2/aa/bb/cc/dd
231-
npm start -- --smoke-test
206+
yarn start --smoke-test
232207

233208
# Testing a path that is half exists
234209
cd "$temp_app_path"
235210
mkdir -p test-app-nested-paths-t3/aa
236211
create_react_app test-app-nested-paths-t3/aa/bb/cc/dd
237212
cd test-app-nested-paths-t3/aa/bb/cc/dd
238-
npm start -- --smoke-test
213+
yarn start --smoke-test
239214

240215
# Cleanup
241216
cleanup

tasks/e2e-kitchensink.sh

+11-44
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ function install_package {
5858

5959
# Install `dependencies`
6060
cd node_modules/$pkg/
61-
npm install --only=production
61+
yarn --production
6262
# Remove our packages to ensure side-by-side versions are used (which we link)
6363
rm -rf node_modules/{babel-preset-react-app,eslint-config-react-app,react-dev-utils,react-error-overlay,react-scripts}
6464
cd ../..
@@ -84,42 +84,17 @@ set -x
8484
cd ..
8585
root_path=$PWD
8686

87-
# Clear cache to avoid issues with incorrect packages being used
88-
if hash yarnpkg 2>/dev/null
89-
then
90-
# AppVeyor uses an old version of yarn.
91-
# Once updated to 0.24.3 or above, the workaround can be removed
92-
# and replaced with `yarnpkg cache clean`
93-
# Issues:
94-
# https://github.com/yarnpkg/yarn/issues/2591
95-
# https://github.com/appveyor/ci/issues/1576
96-
# https://github.com/facebookincubator/create-react-app/pull/2400
97-
# When removing workaround, you may run into
98-
# https://github.com/facebookincubator/create-react-app/issues/2030
99-
case "$(uname -s)" in
100-
*CYGWIN*|MSYS*|MINGW*) yarn=yarn.cmd;;
101-
*) yarn=yarnpkg;;
102-
esac
103-
$yarn cache clean
104-
fi
105-
106-
if hash npm 2>/dev/null
107-
then
108-
npm i -g npm@latest
109-
npm cache clean || npm cache verify
110-
fi
111-
11287
# Prevent bootstrap, we only want top-level dependencies
11388
cp package.json package.json.bak
11489
grep -v "postinstall" package.json > temp && mv temp package.json
115-
npm install
90+
yarn
11691
mv package.json.bak package.json
11792

11893
# We removed the postinstall, so do it manually
11994
node bootstrap.js
12095

12196
cd packages/react-error-overlay/
122-
npm run build:prod
97+
yarn build:prod
12398
cd ../..
12499

125100
# ******************************************************************************
@@ -153,15 +128,15 @@ mv package.json.orig package.json
153128

154129
# Install the CLI in a temporary location
155130
cd "$temp_cli_path"
156-
npm install "$cli_path"
131+
yarn add "$cli_path"
157132

158133
# Install the app in a temporary location
159134
cd $temp_app_path
160135
create_react_app --scripts-version="$scripts_path" --internal-testing-template="$root_path"/packages/react-scripts/fixtures/kitchensink test-kitchensink
161136

162137
# Install the test module
163138
cd "$temp_module_path"
164-
npm install test-integrity@^2.0.1
139+
yarn add test-integrity@^2.0.1
165140

166141
# ******************************************************************************
167142
# Now that we used create-react-app to create an app depending on react-scripts,
@@ -184,7 +159,7 @@ install_package "$temp_module_path/node_modules/test-integrity"
184159
REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \
185160
NODE_PATH=src \
186161
PUBLIC_URL=http://www.example.org/spa/ \
187-
npm run build
162+
yarn build
188163

189164
# Check for expected output
190165
exists build/*.html
@@ -195,14 +170,14 @@ REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \
195170
CI=true \
196171
NODE_PATH=src \
197172
NODE_ENV=test \
198-
npm test -- --no-cache --testPathPattern=src
173+
yarn test --no-cache --testPathPattern=src
199174

200175
# Test "development" environment
201176
tmp_server_log=`mktemp`
202177
PORT=3001 \
203178
REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \
204179
NODE_PATH=src \
205-
nohup npm start &>$tmp_server_log &
180+
nohup yarn start &>$tmp_server_log &
206181
grep -q 'You can now view' <(tail -f $tmp_server_log)
207182
E2E_URL="http://localhost:3001" \
208183
REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \
@@ -225,14 +200,6 @@ E2E_FILE=./build/index.html \
225200
# Eject...
226201
echo yes | npm run eject
227202

228-
# Ensure Yarn is ran after eject; at the time of this commit, we don't run Yarn
229-
# after ejecting. Soon, we may only skip Yarn on Windows. Let's try to remove
230-
# this in the near future.
231-
if hash yarnpkg 2>/dev/null
232-
then
233-
yarn install --check-files
234-
fi
235-
236203
# ...but still link to the local packages
237204
install_package "$root_path"/packages/babel-preset-react-app
238205
install_package "$root_path"/packages/eslint-config-react-app
@@ -246,7 +213,7 @@ install_package "$temp_module_path/node_modules/test-integrity"
246213
REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \
247214
NODE_PATH=src \
248215
PUBLIC_URL=http://www.example.org/spa/ \
249-
npm run build
216+
yarn build
250217

251218
# Check for expected output
252219
exists build/*.html
@@ -257,14 +224,14 @@ REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \
257224
CI=true \
258225
NODE_PATH=src \
259226
NODE_ENV=test \
260-
npm test -- --no-cache --testPathPattern=src
227+
yarn test --no-cache --testPathPattern=src
261228

262229
# Test "development" environment
263230
tmp_server_log=`mktemp`
264231
PORT=3002 \
265232
REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \
266233
NODE_PATH=src \
267-
nohup npm start &>$tmp_server_log &
234+
nohup yarn start &>$tmp_server_log &
268235
grep -q 'You can now view' <(tail -f $tmp_server_log)
269236
E2E_URL="http://localhost:3002" \
270237
REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \

0 commit comments

Comments
 (0)