Skip to content

Commit c5805c2

Browse files
committed
Separate fast e2e testing from kitchensink testing
1 parent aeebbdb commit c5805c2

File tree

5 files changed

+373
-95
lines changed

5 files changed

+373
-95
lines changed

.travis.yml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,27 @@
11
---
22
language: node_js
33
node_js:
4-
- 0.10
54
- 4
65
- 6
76
cache:
87
directories:
98
- node_modules
109
- packages/create-react-app/node_modules
1110
- packages/react-scripts/node_modules
12-
script: tasks/e2e.sh
11+
script:
12+
- 'if [ $TEST_SUITE = "simple" ]; then tasks/e2e-simple.sh; fi'
13+
- 'if [ $TEST_SUITE = "installs" ]; then tasks/e2e-installs.sh; fi'
14+
- 'if [ $TEST_SUITE = "kitchensink" ]; then tasks/e2e-kitchensink.sh; fi'
1315
env:
14-
- USE_YARN=no
15-
- USE_YARN=yes
16+
global:
17+
- USE_YARN=no
18+
matrix:
19+
- TEST_SUITE=simple
20+
- TEST_SUITE=installs
21+
- TEST_SUITE=kitchensink
22+
matrix:
23+
include:
24+
- node_js: 0.10
25+
env: TEST_SUITE=simple
26+
- node_js: 6
27+
env: USE_YARN=yes TEST_SUITE=simple

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"build": "node packages/react-scripts/scripts/build.js",
55
"changelog": "lerna-changelog",
66
"create-react-app": "tasks/cra.sh",
7-
"e2e": "tasks/e2e.sh",
7+
"e2e": "tasks/e2e-simple.sh",
88
"postinstall": "lerna bootstrap",
99
"publish": "tasks/release.sh",
1010
"start": "node packages/react-scripts/scripts/start.js",

tasks/e2e-installs.sh

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
#!/bin/bash
2+
# Copyright (c) 2015-present, Facebook, Inc.
3+
# All rights reserved.
4+
#
5+
# This source code is licensed under the BSD-style license found in the
6+
# LICENSE file in the root directory of this source tree. An additional grant
7+
# of patent rights can be found in the PATENTS file in the same directory.
8+
9+
# ******************************************************************************
10+
# This is an end-to-end test intended to run on CI.
11+
# You can also run it locally but it's slow.
12+
# ******************************************************************************
13+
14+
# Start in tasks/ even if run from root directory
15+
cd "$(dirname "$0")"
16+
17+
# CLI and app temporary locations
18+
# http://unix.stackexchange.com/a/84980
19+
temp_cli_path=`mktemp -d 2>/dev/null || mktemp -d -t 'temp_cli_path'`
20+
temp_app_path=`mktemp -d 2>/dev/null || mktemp -d -t 'temp_app_path'`
21+
22+
function cleanup {
23+
echo 'Cleaning up.'
24+
cd $root_path
25+
# Uncomment when snapshot testing is enabled by default:
26+
# rm ./packages/react-scripts/template/src/__snapshots__/App.test.js.snap
27+
rm -rf $temp_cli_path $temp_app_path
28+
}
29+
30+
# Error messages are redirected to stderr
31+
function handle_error {
32+
echo "$(basename $0): ERROR! An error was encountered executing line $1." 1>&2;
33+
cleanup
34+
echo 'Exiting with error.' 1>&2;
35+
exit 1
36+
}
37+
38+
function handle_exit {
39+
cleanup
40+
echo 'Exiting without error.' 1>&2;
41+
exit
42+
}
43+
44+
function create_react_app {
45+
node "$temp_cli_path"/node_modules/create-react-app/index.js $*
46+
}
47+
48+
# Exit the script with a helpful error message when any error is encountered
49+
trap 'set +x; handle_error $LINENO $BASH_COMMAND' ERR
50+
51+
# Cleanup before exit on any termination signal
52+
trap 'set +x; handle_exit' SIGQUIT SIGTERM SIGINT SIGKILL SIGHUP
53+
54+
# Echo every command being executed
55+
set -x
56+
57+
# Go to root
58+
cd ..
59+
root_path=$PWD
60+
61+
npm install
62+
63+
# If the node version is < 4, the script should just give an error.
64+
if [ `node --version | sed -e 's/^v//' -e 's/\..\+//g'` -lt 4 ]
65+
then
66+
cd $temp_app_path
67+
err_output=`node "$root_path"/packages/create-react-app/index.js test-node-version 2>&1 > /dev/null || echo ''`
68+
[[ $err_output =~ You\ are\ running\ Node ]] && exit 0 || exit 1
69+
fi
70+
71+
if [ "$USE_YARN" = "yes" ]
72+
then
73+
# Install Yarn so that the test can use it to install packages.
74+
npm install -g [email protected] # TODO: remove version when https://github.com/yarnpkg/yarn/issues/2142 is fixed.
75+
yarn cache clean
76+
fi
77+
78+
# ******************************************************************************
79+
# First, pack and install create-react-app.
80+
# ******************************************************************************
81+
82+
# Pack CLI
83+
cd $root_path/packages/create-react-app
84+
cli_path=$PWD/`npm pack`
85+
86+
# Install the CLI in a temporary location
87+
cd $temp_cli_path
88+
npm install $cli_path
89+
90+
# ******************************************************************************
91+
# Test --scripts-version with a version number
92+
# ******************************************************************************
93+
94+
cd $temp_app_path
95+
create_react_app --scripts-version=0.4.0 test-app-version-number
96+
cd test-app-version-number
97+
98+
# Check corresponding scripts version is installed.
99+
test -e node_modules/react-scripts
100+
grep '"version": "0.4.0"' node_modules/react-scripts/package.json
101+
102+
# ******************************************************************************
103+
# Test --scripts-version with a tarball url
104+
# ******************************************************************************
105+
106+
cd $temp_app_path
107+
create_react_app --scripts-version=https://registry.npmjs.org/react-scripts/-/react-scripts-0.4.0.tgz test-app-tarball-url
108+
cd test-app-tarball-url
109+
110+
# Check corresponding scripts version is installed.
111+
test -e node_modules/react-scripts
112+
grep '"version": "0.4.0"' node_modules/react-scripts/package.json
113+
114+
# ******************************************************************************
115+
# Test --scripts-version with a custom fork of react-scripts
116+
# ******************************************************************************
117+
118+
cd $temp_app_path
119+
create_react_app --scripts-version=react-scripts-fork test-app-fork
120+
cd test-app-fork
121+
122+
# Check corresponding scripts version is installed.
123+
test -e node_modules/react-scripts-fork
124+
125+
# ******************************************************************************
126+
# Test nested folder path as the project name
127+
# ******************************************************************************
128+
129+
#Testing a path that exists
130+
cd $temp_app_path
131+
mkdir test-app-nested-paths-t1
132+
cd test-app-nested-paths-t1
133+
mkdir -p test-app-nested-paths-t1/aa/bb/cc/dd
134+
create_react_app test-app-nested-paths-t1/aa/bb/cc/dd
135+
cd test-app-nested-paths-t1/aa/bb/cc/dd
136+
npm start -- --smoke-test
137+
138+
#Testing a path that does not exist
139+
cd $temp_app_path
140+
create_react_app test-app-nested-paths-t2/aa/bb/cc/dd
141+
cd test-app-nested-paths-t2/aa/bb/cc/dd
142+
npm start -- --smoke-test
143+
144+
#Testing a path that is half exists
145+
cd $temp_app_path
146+
mkdir -p test-app-nested-paths-t3/aa
147+
create_react_app test-app-nested-paths-t3/aa/bb/cc/dd
148+
cd test-app-nested-paths-t3/aa/bb/cc/dd
149+
npm start -- --smoke-test
150+
151+
# Cleanup
152+
cleanup

tasks/e2e.sh renamed to tasks/e2e-kitchensink.sh

Lines changed: 4 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# of patent rights can be found in the PATENTS file in the same directory.
88

99
# ******************************************************************************
10-
# This is an end-to-end test intended to run on CI.
10+
# This is an end-to-end kitchensink test intended to run on CI.
1111
# You can also run it locally but it's slow.
1212
# ******************************************************************************
1313

@@ -75,33 +75,8 @@ then
7575
yarn cache clean
7676
fi
7777

78-
# Lint own code
79-
./node_modules/.bin/eslint --ignore-path .gitignore ./
80-
8178
# ******************************************************************************
82-
# First, test the create-react-app development environment.
83-
# This does not affect our users but makes sure we can develop it.
84-
# ******************************************************************************
85-
86-
# Test local build command
87-
npm run build
88-
# Check for expected output
89-
test -e build/*.html
90-
test -e build/static/js/main.*.js
91-
test -e build/static/css/main.*.css
92-
test -e build/static/media/*.svg
93-
test -e build/favicon.ico
94-
95-
# Run tests with CI flag
96-
CI=true npm test
97-
# Uncomment when snapshot testing is enabled by default:
98-
# test -e template/src/__snapshots__/App.test.js.snap
99-
100-
# Test local start command
101-
npm start -- --smoke-test
102-
103-
# ******************************************************************************
104-
# Next, pack react-scripts and create-react-app so we can verify they work.
79+
# First, pack react-scripts and create-react-app so we can use them.
10580
# ******************************************************************************
10681

10782
# Pack CLI
@@ -138,15 +113,15 @@ npm install $cli_path
138113

139114
# Install the app in a temporary location
140115
cd $temp_app_path
141-
create_react_app --scripts-version=$scripts_path --template=$root_path/packages/react-scripts/fixtures/kitchensink test-app
116+
create_react_app --scripts-version=$scripts_path --template=$root_path/packages/react-scripts/fixtures/kitchensink test-kitchensink
142117

143118
# ******************************************************************************
144119
# Now that we used create-react-app to create an app depending on react-scripts,
145120
# let's make sure all npm scripts are in the working state.
146121
# ******************************************************************************
147122

148123
# Enter the app directory
149-
cd test-app
124+
cd test-kitchensink
150125

151126
# Test the build
152127
NODE_PATH=src REACT_APP_SHELL_ENV_MESSAGE=fromtheshell npm run build
@@ -239,66 +214,5 @@ E2E_FILE=./build/index.html \
239214
# Test the server
240215
REACT_APP_SHELL_ENV_MESSAGE=fromtheshell NODE_PATH=src npm start -- --smoke-test
241216

242-
# ******************************************************************************
243-
# Test --scripts-version with a version number
244-
# ******************************************************************************
245-
246-
cd $temp_app_path
247-
create_react_app --scripts-version=0.4.0 test-app-version-number
248-
cd test-app-version-number
249-
250-
# Check corresponding scripts version is installed.
251-
test -e node_modules/react-scripts
252-
grep '"version": "0.4.0"' node_modules/react-scripts/package.json
253-
254-
# ******************************************************************************
255-
# Test --scripts-version with a tarball url
256-
# ******************************************************************************
257-
258-
cd $temp_app_path
259-
create_react_app --scripts-version=https://registry.npmjs.org/react-scripts/-/react-scripts-0.4.0.tgz test-app-tarball-url
260-
cd test-app-tarball-url
261-
262-
# Check corresponding scripts version is installed.
263-
test -e node_modules/react-scripts
264-
grep '"version": "0.4.0"' node_modules/react-scripts/package.json
265-
266-
# ******************************************************************************
267-
# Test --scripts-version with a custom fork of react-scripts
268-
# ******************************************************************************
269-
270-
cd $temp_app_path
271-
create_react_app --scripts-version=react-scripts-fork test-app-fork
272-
cd test-app-fork
273-
274-
# Check corresponding scripts version is installed.
275-
test -e node_modules/react-scripts-fork
276-
277-
# ******************************************************************************
278-
# Test nested folder path as the project name
279-
# ******************************************************************************
280-
281-
#Testing a path that exists
282-
cd $temp_app_path
283-
mkdir test-app-nested-paths-t1
284-
cd test-app-nested-paths-t1
285-
mkdir -p test-app-nested-paths-t1/aa/bb/cc/dd
286-
create_react_app test-app-nested-paths-t1/aa/bb/cc/dd
287-
cd test-app-nested-paths-t1/aa/bb/cc/dd
288-
npm start -- --smoke-test
289-
290-
#Testing a path that does not exist
291-
cd $temp_app_path
292-
create_react_app test-app-nested-paths-t2/aa/bb/cc/dd
293-
cd test-app-nested-paths-t2/aa/bb/cc/dd
294-
npm start -- --smoke-test
295-
296-
#Testing a path that is half exists
297-
cd $temp_app_path
298-
mkdir -p test-app-nested-paths-t3/aa
299-
create_react_app test-app-nested-paths-t3/aa/bb/cc/dd
300-
cd test-app-nested-paths-t3/aa/bb/cc/dd
301-
npm start -- --smoke-test
302-
303217
# Cleanup
304218
cleanup

0 commit comments

Comments
 (0)