Skip to content

Commit d3f9305

Browse files
committed
Add end to end test
1 parent bb50351 commit d3f9305

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

tests/e2e.sh

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Copyright (c) 2015-present, Facebook, Inc.
2+
# All rights reserved.
3+
#
4+
# This source code is licensed under the BSD-style license found in the
5+
# LICENSE file in the root directory of this source tree. An additional grant
6+
# of patent rights can be found in the PATENTS file in the same directory.
7+
8+
# Start in tests/ even if run from root directory
9+
cd "$(dirname "$0")"
10+
11+
# Exit the script on any command with non 0 return code
12+
# We assume that all the commands in the pipeline set their return code
13+
# properly and that we do not need to validate that the output is correct
14+
set -e
15+
16+
# Echo every command being executed
17+
set -x
18+
19+
# npm pack the two directories to make sure they are valid npm modules
20+
initial_path=$PWD
21+
cd ..
22+
npm install
23+
scripts_path=$PWD/`npm pack`
24+
cd global-cli
25+
npm install
26+
cli_path=$PWD/`npm pack`
27+
28+
# Install the cli in a temporary location ( http://unix.stackexchange.com/a/84980 )
29+
temp_cli_path=`mktemp -d 2>/dev/null || mktemp -d -t 'temp_cli_path'`
30+
cd $temp_cli_path
31+
npm install $cli_path
32+
33+
# Install the app in a temporary location
34+
temp_app_path=`mktemp -d 2>/dev/null || mktemp -d -t 'temp_app_path'`
35+
cd $temp_app_path
36+
node "$temp_cli_path"/node_modules/create-react-app/index.js --scripts-version=$scripts_path test-app
37+
cd test-app
38+
39+
# Test the build
40+
npm run build
41+
42+
# Eject and test the build
43+
echo yes | npm run eject
44+
npm run build
45+
46+
# Cleanup
47+
cd $initial_path
48+
rm -rf $temp_cli_path $temp_app_path

0 commit comments

Comments
 (0)