@@ -142,6 +142,55 @@ create_react_app --scripts-version=$scripts_path test-app
142142# let's make sure all npm scripts are in the working state.
143143# ******************************************************************************
144144
145+ function verify_env_url {
146+ # Backup package.json because we're going to make it dirty
147+ cp package.json package.json.orig
148+
149+ # Test default behavior
150+ grep -F -R --exclude=* .map " \" /static/" build/ -q; test $? -eq 0 || exit 1
151+
152+ # Test relative path build
153+ awk -v n=2 -v s=" \" homepage\" : \" .\" ," ' NR == n {print s} {print}' package.json > tmp && mv tmp package.json
154+
155+ npm run build
156+ # Disabled until this can be tested
157+ # grep -F -R --exclude=*.map "../../static/" build/ -q; test $? -eq 0 || exit 1
158+ grep -F -R --exclude=* .map " \" ./static/" build/ -q; test $? -eq 0 || exit 1
159+ grep -F -R --exclude=* .map " \" /static/" build/ -q; test $? -eq 1 || exit 1
160+
161+ PUBLIC_URL=" /anabsolute" npm run build
162+ grep -F -R --exclude=* .map " /anabsolute/static/" build/ -q; test $? -eq 0 || exit 1
163+ grep -F -R --exclude=* .map " \" /static/" build/ -q; test $? -eq 1 || exit 1
164+
165+ # Test absolute path build
166+ sed " 2s/.*/ \" homepage\" : \" \/testingpath\" ,/" package.json > tmp && mv tmp package.json
167+
168+ npm run build
169+ grep -F -R --exclude=* .map " /testingpath/static/" build/ -q; test $? -eq 0 || exit 1
170+ grep -F -R --exclude=* .map " \" /static/" build/ -q; test $? -eq 1 || exit 1
171+
172+ PUBLIC_URL=" https://www.example.net/overridetest" npm run build
173+ grep -F -R --exclude=* .map " https://www.example.net/overridetest/static/" build/ -q; test $? -eq 0 || exit 1
174+ grep -F -R --exclude=* .map " \" /static/" build/ -q; test $? -eq 1 || exit 1
175+ grep -F -R --exclude=* .map " testingpath/static" build/ -q; test $? -eq 1 || exit 1
176+
177+ # Test absolute url build
178+ sed " 2s/.*/ \" homepage\" : \" https:\/\/www.example.net\/testingpath\" ,/" package.json > tmp && mv tmp package.json
179+
180+ npm run build
181+ grep -F -R --exclude=* .map " /testingpath/static/" build/ -q; test $? -eq 0 || exit 1
182+ grep -F -R --exclude=* .map " \" /static/" build/ -q; test $? -eq 1 || exit 1
183+
184+ PUBLIC_URL=" https://www.example.net/overridetest" npm run build
185+ grep -F -R --exclude=* .map " https://www.example.net/overridetest/static/" build/ -q; test $? -eq 0 || exit 1
186+ grep -F -R --exclude=* .map " \" /static/" build/ -q; test $? -eq 1 || exit 1
187+ grep -F -R --exclude=* .map " testingpath/static" build/ -q; test $? -eq 1 || exit 1
188+
189+ # Restore package.json
190+ rm package.json
191+ mv package.json.orig package.json
192+ }
193+
145194# Enter the app directory
146195cd test-app
147196
@@ -162,6 +211,9 @@ CI=true npm test
162211# Test the server
163212npm start -- --smoke-test
164213
214+ # Test environment handling
215+ verify_env_url
216+
165217# ******************************************************************************
166218# Finally, let's check that everything still works after ejecting.
167219# ******************************************************************************
@@ -195,6 +247,8 @@ npm test -- --watch=no
195247# Test the server
196248npm start -- --smoke-test
197249
250+ # Test environment handling
251+ verify_env_url
198252
199253# Cleanup
200254cleanup
0 commit comments