1
- #! /bin/bash
2
1
# Copyright (c) 2015-present, Facebook, Inc.
3
2
# All rights reserved.
4
3
#
@@ -29,6 +28,27 @@ function handle_exit {
29
28
exit
30
29
}
31
30
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
+
32
52
# Exit the script with a helpful error message when any error is encountered
33
53
trap ' set +x; handle_error $LINENO $BASH_COMMAND' ERR
34
54
@@ -55,23 +75,8 @@ scripts_path=$PWD/`npm pack`
55
75
56
76
# lint
57
77
./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"
75
80
76
81
# Pack CLI
77
82
cd global-cli
@@ -90,39 +95,12 @@ node "$temp_cli_path"/node_modules/create-react-app/index.js --scripts-version=$
90
95
cd test-app
91
96
92
97
# 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"
108
99
109
100
# Eject and test the build
110
101
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"
126
104
127
105
# Cleanup
128
106
cleanup
0 commit comments