docbrown/bin/e2e

32 lines
1.1 KiB
Bash
Executable file

#!/bin/bash
printf "Doing a quick bundle check to make sure gems are all up to date.\n\n"
bundle check # ensure gems are up to date
if [ $? -eq 1 ]; then
echo "Unable to launch end to end tests. Ensure that all your gems are installed and up to date."
exit;
fi
yarn install # ensure npm packages are up to date
if [ $? -eq 1 ]; then
echo "Unable to launch end to end tests. An error occurred while running yarn install."
exit;
fi
printf "\n"
# Wait 10 seconds and if the user does not respond, assume they do not want to rebuild the test E2E database
read -t 10 -p "Choose yes to setup a test database or if you're running the script for the first time, choose no or wait 10 seconds otherwise (y/n) " -n 1 -r
if [[ $REPLY =~ ^[Yy]$ ]]; then
printf "\n\nSetting up the E2E database before running E2E tests...\n\n"
RAILS_ENV=test E2E=true bin/e2e-setup
else
printf "\n\nSkipping database setup...\n\n"
fi
printf "Starting the test runner...\n\n"
bundle exec rails assets:precompile;
CYPRESS_RAILS_CYPRESS_OPTS="--config-file cypress.dev.json" RAILS_ENV=test E2E=true bundle exec rake cypress:open