Skip to content

Commit

Permalink
TC-47 test cypress
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniil Tkachev committed Jan 13, 2025
1 parent e51a53d commit f9bab43
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions .github/oxid-esales/cypress.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,28 @@ function debug_cypress_container() {
docker inspect cypress-container --format='{{json .State}}'
}

function wait_for_application() {
echo "Waiting for application at http://oxideshop.local to be ready..."
until docker exec cypress-container curl -s http://oxideshop.local >/dev/null; do
sleep 2
done
echo "Application is ready!"
}


function run_cypress_tests_and_stream_logs() {
echo "Running Cypress tests and streaming logs to GitHub Actions console..."

# Run Cypress tests and capture logs
docker exec cypress-container npx cypress run --config-file /var/www/cypress.config.js 2>&1 | tee cypress-test-output.log
# Run Cypress tests with detailed logging
docker exec cypress-container npx cypress run --browser chrome --headless --config-file /var/www/cypress.config.js --reporter spec 2>&1 | tee cypress-test-output.log

# Display the entire log for debugging
# Display the full log
echo -e "${RED}Cypress test logs:${NC}"
cat cypress-test-output.log

# Check for failure
# Check for success
if ! grep -q "All specs passed!" cypress-test-output.log; then
echo -e "${RED}Cypress tests failed. The above logs contain detailed error information.${NC}"
echo -e "${RED}Cypress tests failed. Check the logs above for details.${NC}"
exit 1
fi

Expand All @@ -80,5 +89,6 @@ function cleanup() {
create_network
start_services
setup_cypress
wait_for_application
run_cypress_tests_and_stream_logs
cleanup

0 comments on commit f9bab43

Please sign in to comment.