Skip to content

Commit

Permalink
f
Browse files Browse the repository at this point in the history
  • Loading branch information
Jiansen committed Aug 20, 2016
1 parent b93e6c0 commit 3eddc77
Showing 1 changed file with 26 additions and 48 deletions.
74 changes: 26 additions & 48 deletions tasks/e2e.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/bin/bash
# Copyright (c) 2015-present, Facebook, Inc.
# All rights reserved.
#
Expand Down Expand Up @@ -29,6 +28,27 @@ function handle_exit {
exit
}

function build_check {
local test_snap_path="$1"

# Test the build command
npm run build

# Check for expected output
test -e build/*.html
test -e build/static/js/*.js
test -e build/static/css/*.css
test -e build/static/media/*.svg
test -e build/favicon.ico

# Run Jest tests
npm run test
test -e $test_snap_path

# Test the server
npm start -- --smoke-test
}

# Exit the script with a helpful error message when any error is encountered
trap 'set +x; handle_error $LINENO $BASH_COMMAND' ERR

Expand All @@ -55,23 +75,8 @@ scripts_path=$PWD/`npm pack`

# lint
./node_modules/.bin/eslint --ignore-path .gitignore ./

# Test local start command
npm start -- --smoke-test

# Test local build command
npm run build

# Check for expected output
test -e build/*.html
test -e build/static/js/*.js
test -e build/static/css/*.css
test -e build/static/media/*.svg
test -e build/favicon.ico

# Run tests
npm run test
test -e template/src/__tests__/__snapshots__/App-test.js.snap
# Test the build
build_check "template/src/__tests__/__snapshots__/App-test.js.snap"

# Pack CLI
cd global-cli
Expand All @@ -90,39 +95,12 @@ node "$temp_cli_path"/node_modules/create-react-app/index.js --scripts-version=$
cd test-app

# Test the build
npm run build

# Check for expected output
test -e build/*.html
test -e build/static/js/*.js
test -e build/static/css/*.css
test -e build/static/media/*.svg
test -e build/favicon.ico

# Run tests
npm run test
test -e src/__tests__/__snapshots__/App-test.js.snap

# Test the server
npm start -- --smoke-test
build_check "src/__tests__/__snapshots__/App-test.js.snap"

# Eject and test the build
echo yes | npm run eject
npm run build

# Check for expected output
test -e build/*.html
test -e build/static/js/*.js
test -e build/static/css/*.css
test -e build/static/media/*.svg
test -e build/favicon.ico

# Run tests
npm run test
test -e src/__tests__/__snapshots__/App-test.js.snap

# Test the server
npm start -- --smoke-test
# Test the build
build_check "src/__tests__/__snapshots__/App-test.js.snap"

# Cleanup
cleanup

0 comments on commit 3eddc77

Please sign in to comment.