woocommerce/packages/js/e2e-environment/bin/wc-e2e.sh

71 lines
1.6 KiB
Bash
Raw Normal View History

2020-12-15 17:54:59 +00:00
#!/usr/bin/env bash
#
# Run package scripts
#
# Script help
usage() {
echo 'usage: npx wc-e2e <script>'
echo 'scripts:'
echo ' docker:up [initialization-script] - boot docker container'
echo ' docker:down - shut down docker container'
echo ' docker:ssh - open SSH shell into docker container'
echo ' docker:clear-all - remove all docker containers'
echo ' test:e2e [test-script] - run e2e test suite or specific test-script'
echo ' test:e2e-dev [test-script] - run e2e test(s) in non-headless mode'
echo ' test:e2e-debug [test-script] - run e2e test(s) in non-headless debug mode'
}
# Parameter check
if [ $# -lt 1 ]; then
usage
exit 1
fi
# Store original path
OLDPATH=$(pwd)
# Return value for CI test runs
TESTRESULT=0
2020-12-15 17:54:59 +00:00
# Use the script symlink to find and change directory to the root of the package
SCRIPTPATH=$(dirname "$0")
REALPATH=$(readlink "$0")
cd "$SCRIPTPATH/$(dirname "$REALPATH")/.."
2020-12-15 17:54:59 +00:00
# Run scripts
case $1 in
'docker:up')
./bin/docker-compose.sh up $2
;;
'docker:down')
./bin/docker-compose.sh down
;;
'docker:ssh')
docker exec -it $(node utils/get-app-name.js)_wordpress-www /bin/bash
;;
'docker:clear-all')
docker rmi --force $(docker images -q)
;;
'test:e2e')
./bin/wait-for-build.sh && ./bin/e2e-test-integration.js $2
TESTRESULT=$?
2020-12-15 17:54:59 +00:00
;;
'test:e2e-dev')
./bin/wait-for-build.sh && ./bin/e2e-test-integration.js --dev $2
TESTRESULT=$?
2020-12-15 17:54:59 +00:00
;;
'test:e2e-debug')
./bin/wait-for-build.sh && ./bin/e2e-test-integration.js --dev --debug $2
TESTRESULT=$?
2020-12-15 17:54:59 +00:00
;;
*)
usage
;;
esac
# Restore working path
cd "$OLDPATH"
exit $TESTRESULT