Skip to content

Commit 3eddc77

Browse files
committed
f
1 parent b93e6c0 commit 3eddc77

File tree

1 file changed

+26
-48
lines changed

1 file changed

+26
-48
lines changed

tasks/e2e.sh

+26-48
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#!/bin/bash
21
# Copyright (c) 2015-present, Facebook, Inc.
32
# All rights reserved.
43
#
@@ -29,6 +28,27 @@ function handle_exit {
2928
exit
3029
}
3130

31+
function build_check {
32+
local test_snap_path="$1"
33+
34+
# Test the build command
35+
npm run build
36+
37+
# Check for expected output
38+
test -e build/*.html
39+
test -e build/static/js/*.js
40+
test -e build/static/css/*.css
41+
test -e build/static/media/*.svg
42+
test -e build/favicon.ico
43+
44+
# Run Jest tests
45+
npm run test
46+
test -e $test_snap_path
47+
48+
# Test the server
49+
npm start -- --smoke-test
50+
}
51+
3252
# Exit the script with a helpful error message when any error is encountered
3353
trap 'set +x; handle_error $LINENO $BASH_COMMAND' ERR
3454

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

5676
# lint
5777
./node_modules/.bin/eslint --ignore-path .gitignore ./
58-
59-
# Test local start command
60-
npm start -- --smoke-test
61-
62-
# Test local build command
63-
npm run build
64-
65-
# Check for expected output
66-
test -e build/*.html
67-
test -e build/static/js/*.js
68-
test -e build/static/css/*.css
69-
test -e build/static/media/*.svg
70-
test -e build/favicon.ico
71-
72-
# Run tests
73-
npm run test
74-
test -e template/src/__tests__/__snapshots__/App-test.js.snap
78+
# Test the build
79+
build_check "template/src/__tests__/__snapshots__/App-test.js.snap"
7580

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

9297
# Test the build
93-
npm run build
94-
95-
# Check for expected output
96-
test -e build/*.html
97-
test -e build/static/js/*.js
98-
test -e build/static/css/*.css
99-
test -e build/static/media/*.svg
100-
test -e build/favicon.ico
101-
102-
# Run tests
103-
npm run test
104-
test -e src/__tests__/__snapshots__/App-test.js.snap
105-
106-
# Test the server
107-
npm start -- --smoke-test
98+
build_check "src/__tests__/__snapshots__/App-test.js.snap"
10899

109100
# Eject and test the build
110101
echo yes | npm run eject
111-
npm run build
112-
113-
# Check for expected output
114-
test -e build/*.html
115-
test -e build/static/js/*.js
116-
test -e build/static/css/*.css
117-
test -e build/static/media/*.svg
118-
test -e build/favicon.ico
119-
120-
# Run tests
121-
npm run test
122-
test -e src/__tests__/__snapshots__/App-test.js.snap
123-
124-
# Test the server
125-
npm start -- --smoke-test
102+
# Test the build
103+
build_check "src/__tests__/__snapshots__/App-test.js.snap"
126104

127105
# Cleanup
128106
cleanup

0 commit comments

Comments
 (0)