Skip to content

Commit 8376e19

Browse files
committed
Merge pull request #805 from frantic/e2e-test
Add end-to-end test
2 parents 6b91f7e + 9024881 commit 8376e19

File tree

4 files changed

+83
-0
lines changed

4 files changed

+83
-0
lines changed

.travis.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ before_install:
88
- brew update
99
install:
1010
- brew reinstall flow watchman xctool
11+
- npm config set spin=false
1112
- npm install
1213

1314
script:
@@ -47,6 +48,9 @@ script:
4748
node server/generate.js
4849
fi
4950
51+
elif [ "$TEST_TYPE" = e2e ]
52+
then
53+
./scripts/e2e-test.sh
5054
else
5155
echo "Unknown test type: $TEST_TYPE"
5256
exit 1
@@ -57,6 +61,7 @@ env:
5761
- TEST_TYPE=objc
5862
- TEST_TYPE=js
5963
- TEST_TYPE=build_website
64+
- TEST_TYPE=e2e
6065
global:
6166
- secure: "HlmG8M2DmBUSBh6KH1yVIe/8gR4iibg4WfcHq1x/xYQxGbvleq7NOo04V6eFHnl9cvZCu+PKH0841WLnGR7c4BBf47GVu/o16nXzggPumHKy++lDzxFPlJ1faMDfjg/5vjbAxRUe7D3y98hQSeGHH4tedc8LvTaFLVu7iiGqvjU="
6267

scripts/e2e-npmrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
; travis:travis
2+
_auth=dHJhdmlzOnRyYXZpcw==
3+
4+
spin=false
5+
registry=http://localhost:4873/

scripts/e2e-sinopia.config.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
storage: /tmp/sinopia-package-cache
2+
3+
uplinks:
4+
npmjs:
5+
url: https://registry.npmjs.org/
6+
7+
packages:
8+
'react-native':
9+
allow_access: $all
10+
allow_publish: $all
11+
12+
'react-native-cli':
13+
allow_access: $all
14+
allow_publish: $all
15+
16+
'*':
17+
allow_access: $all
18+
proxy: npmjs
19+
20+
logs:
21+
- {type: file, path: sinopia.log, format: pretty, level: http}

scripts/e2e-test.sh

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/bin/bash
2+
3+
# Abort the mission if any command fails
4+
set -e
5+
6+
SCRIPTS=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
7+
ROOT=$(dirname $SCRIPTS)
8+
TEMP=$(mktemp -d /tmp/react-native-XXXXXXXX)
9+
10+
# To make sure we actually installed the local version
11+
# of react-native, we will create a temp file inside SampleApp
12+
# and check that it exists after `react-native init`
13+
MARKER=$(mktemp $ROOT/Examples/SampleApp/XXXXXXXX)
14+
15+
function cleanup {
16+
rm $MARKER
17+
[ $SINOPIA_PID ] && kill -9 $SINOPIA_PID
18+
[ -f ~/.npmrc.bak ] && mv ~/.npmrc.bak ~/.npmrc
19+
}
20+
trap cleanup EXIT
21+
22+
cd $TEMP
23+
24+
# sinopia is npm registry proxy, it is used to make npm
25+
# think react-native and react-native-cli are actually
26+
# published on npm
27+
which sinopia || npm install -g sinopia
28+
29+
# but in order to make npm use sinopia we temporarily
30+
# replace its config file
31+
[ -f ~/.npmrc ] && cp ~/.npmrc ~/.npmrc.bak
32+
cp $SCRIPTS/e2e-npmrc ~/.npmrc
33+
34+
sinopia --config $SCRIPTS/e2e-sinopia.config.yml &
35+
SINOPIA_PID=$!
36+
37+
# Make sure to remove old version of react-native in
38+
# case it was cached
39+
npm unpublish react-native --force
40+
npm unpublish react-native-cli --force
41+
npm publish $ROOT
42+
npm publish $ROOT/react-native-cli
43+
44+
45+
npm install -g react-native-cli
46+
react-native init EndToEndTest
47+
cd EndToEndTest
48+
49+
# Make sure we installed local version of react-native
50+
ls `basename $MARKER` > /dev/null
51+
52+
xctool -scheme EndToEndTest -sdk iphonesimulator test

0 commit comments

Comments
 (0)