Skip to content
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

Add test cases for PUBLIC_URL and relative path #1519

Merged
merged 6 commits into from
Feb 11, 2017
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Exit on failure
  • Loading branch information
Timer committed Feb 10, 2017
commit f955c9f96289118d07b3afde4b418d0b4b086cb1
30 changes: 15 additions & 15 deletions tasks/e2e-simple.sh
Original file line number Diff line number Diff line change
Expand Up @@ -147,42 +147,42 @@ function verify_env_url {
cp package.json package.json.orig

# Test default behavior
grep -F -R --exclude=*.map "\"/static/" build/ -q; test $? -eq 0
grep -F -R --exclude=*.map "\"/static/" build/ -q; test $? -eq 0 || exit 1

# Test relative path build
awk -v n=2 -v s=" \"homepage\": \".\"," 'NR == n {print s} {print}' package.json > tmp && mv tmp package.json

npm run build
grep -F -R --exclude=*.map "../../static/" build/ -q; test $? -eq 0
grep -F -R --exclude=*.map "\"/static/" build/ -q; test $? -eq 1
grep -F -R --exclude=*.map "../../static/" build/ -q; test $? -eq 0 || exit 1
grep -F -R --exclude=*.map "\"/static/" build/ -q; test $? -eq 1 || exit 1

PUBLIC_URL="/anabsolute" npm run build
grep -F -R --exclude=*.map "/anabsolute/static/" build/ -q; test $? -eq 0
grep -F -R --exclude=*.map "\"/static/" build/ -q; test $? -eq 1
grep -F -R --exclude=*.map "/anabsolute/static/" build/ -q; test $? -eq 0 || exit 1
grep -F -R --exclude=*.map "\"/static/" build/ -q; test $? -eq 1 || exit 1

# Test absolute path build
sed "2s/.*/ \"homepage\": \"\/testingpath\",/" package.json > tmp && mv tmp package.json

npm run build
grep -F -R --exclude=*.map "/testingpath/static/" build/ -q; test $? -eq 0
grep -F -R --exclude=*.map "\"/static/" build/ -q; test $? -eq 1
grep -F -R --exclude=*.map "/testingpath/static/" build/ -q; test $? -eq 0 || exit 1
grep -F -R --exclude=*.map "\"/static/" build/ -q; test $? -eq 1 || exit 1

PUBLIC_URL="https://www.example.net/overridetest" npm run build
grep -F -R --exclude=*.map "https://www.example.net/overridetest/static/" build/ -q; test $? -eq 0
grep -F -R --exclude=*.map "\"/static/" build/ -q; test $? -eq 1
grep -F -R --exclude=*.map "testingpath/static" build/ -q; test $? -eq 1
grep -F -R --exclude=*.map "https://www.example.net/overridetest/static/" build/ -q; test $? -eq 0 || exit 1
grep -F -R --exclude=*.map "\"/static/" build/ -q; test $? -eq 1 || exit 1
grep -F -R --exclude=*.map "testingpath/static" build/ -q; test $? -eq 1 || exit 1

# Test absolute url build
sed "2s/.*/ \"homepage\": \"https:\/\/www.example.net\/testingpath\",/" package.json > tmp && mv tmp package.json

npm run build
grep -F -R --exclude=*.map "/testingpath/static/" build/ -q; test $? -eq 0
grep -F -R --exclude=*.map "\"/static/" build/ -q; test $? -eq 1
grep -F -R --exclude=*.map "/testingpath/static/" build/ -q; test $? -eq 0 || exit 1
grep -F -R --exclude=*.map "\"/static/" build/ -q; test $? -eq 1 || exit 1

PUBLIC_URL="https://www.example.net/overridetest" npm run build
grep -F -R --exclude=*.map "https://www.example.net/overridetest/static/" build/ -q; test $? -eq 0
grep -F -R --exclude=*.map "\"/static/" build/ -q; test $? -eq 1
grep -F -R --exclude=*.map "testingpath/static" build/ -q; test $? -eq 1
grep -F -R --exclude=*.map "https://www.example.net/overridetest/static/" build/ -q; test $? -eq 0 || exit 1
grep -F -R --exclude=*.map "\"/static/" build/ -q; test $? -eq 1 || exit 1
grep -F -R --exclude=*.map "testingpath/static" build/ -q; test $? -eq 1 || exit 1

# Restore package.json
rm package.json
Expand Down