docbrown/bin/e2e

46 lines
1.7 KiB
Bash
Executable file

#!/bin/bash
# Setting the port that the Rails app launches on for a stable app domain in permalinks
# (otherwise, Cypress chooses a random port each run)
# Choosing 30300 here to avoid conflicts with local dev on :3000
export CYPRESS_RAILS_HOST="localhost"
export CYPRESS_RAILS_PORT="30300"
export APP_DOMAIN="localhost:30300"
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;
if [ "$1" = "--creator-onboarding-seed" ]; then
echo "Running E2E tests with creator onboarding seed data"
CYPRESS_RAILS_CYPRESS_OPTS="--config-file cypress.dev.config.js --e2e" RAILS_ENV=test E2E=true CREATOR_ONBOARDING_SEED_DATA=1 E2E_FOLDER=creatorOnboardingFlows bundle exec rake cypress:open
else
CYPRESS_RAILS_CYPRESS_OPTS="--config-file cypress.dev.config.js --e2e" RAILS_ENV=test E2E=true bundle exec rake cypress:open
fi