Skip to content

Add end-to-end test #805

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 11, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ before_install:
- brew update
install:
- brew reinstall flow watchman xctool
- npm config set spin=false
- npm install

script:
Expand Down Expand Up @@ -47,6 +48,9 @@ script:
node server/generate.js
fi

elif [ "$TEST_TYPE" = e2e ]
then
./scripts/e2e-test.sh
else
echo "Unknown test type: $TEST_TYPE"
exit 1
Expand All @@ -57,6 +61,7 @@ env:
- TEST_TYPE=objc
- TEST_TYPE=js
- TEST_TYPE=build_website
- TEST_TYPE=e2e
global:
- secure: "HlmG8M2DmBUSBh6KH1yVIe/8gR4iibg4WfcHq1x/xYQxGbvleq7NOo04V6eFHnl9cvZCu+PKH0841WLnGR7c4BBf47GVu/o16nXzggPumHKy++lDzxFPlJ1faMDfjg/5vjbAxRUe7D3y98hQSeGHH4tedc8LvTaFLVu7iiGqvjU="

Expand Down
5 changes: 5 additions & 0 deletions scripts/e2e-npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
; travis:travis
_auth=dHJhdmlzOnRyYXZpcw==
[email protected]
spin=false
registry=http://localhost:4873/
21 changes: 21 additions & 0 deletions scripts/e2e-sinopia.config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
storage: /tmp/sinopia-package-cache

uplinks:
npmjs:
url: https://registry.npmjs.org/

packages:
'react-native':
allow_access: $all
allow_publish: $all

'react-native-cli':
allow_access: $all
allow_publish: $all

'*':
allow_access: $all
proxy: npmjs

logs:
- {type: file, path: sinopia.log, format: pretty, level: http}
52 changes: 52 additions & 0 deletions scripts/e2e-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/bin/bash

# Abort the mission if any command fails
set -e

SCRIPTS=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
ROOT=$(dirname $SCRIPTS)
TEMP=$(mktemp -d /tmp/react-native-XXXXXXXX)

# To make sure we actually installed the local version
# of react-native, we will create a temp file inside SampleApp
# and check that it exists after `react-native init`
MARKER=$(mktemp $ROOT/Examples/SampleApp/XXXXXXXX)

function cleanup {
rm $MARKER
[ $SINOPIA_PID ] && kill -9 $SINOPIA_PID
[ -f ~/.npmrc.bak ] && mv ~/.npmrc.bak ~/.npmrc
}
trap cleanup EXIT

cd $TEMP

# sinopia is npm registry proxy, it is used to make npm
# think react-native and react-native-cli are actually
# published on npm
which sinopia || npm install -g sinopia

# but in order to make npm use sinopia we temporarily
# replace its config file
[ -f ~/.npmrc ] && cp ~/.npmrc ~/.npmrc.bak
cp $SCRIPTS/e2e-npmrc ~/.npmrc

sinopia --config $SCRIPTS/e2e-sinopia.config.yml &
SINOPIA_PID=$!

# Make sure to remove old version of react-native in
# case it was cached
npm unpublish react-native --force
npm unpublish react-native-cli --force
npm publish $ROOT
npm publish $ROOT/react-native-cli


npm install -g react-native-cli
react-native init EndToEndTest
cd EndToEndTest

# Make sure we installed local version of react-native
ls `basename $MARKER` > /dev/null

xctool -scheme EndToEndTest -sdk iphonesimulator test