test: test card payment with multiple card brands #423
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Run Cypress Tests | |
on: | |
pull_request: | |
merge_group: | |
push: | |
branches: | |
- main | |
jobs: | |
cypress: | |
runs-on: ubuntu-latest | |
environment: Testing | |
# timeout-minutes: 15 # Added overall job timeout | |
env: | |
HS_Prof_Id: ${{ secrets.PROFILE_ID }} | |
HS_Server_Url: "https://sandbox.hyperswitch.io" | |
HS_Client_Url: "http://localhost:9050" | |
# Environment variables for Hyperswitch credentials and URLs | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
# Checks out the repository so that the workflow can access the code | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: "20" # Specifies the version of Node.js to use | |
cache: "npm" # Caches npm dependencies to speed up subsequent installs | |
- name: Install dependencies | |
run: | | |
npm ci # Recommended over npm install for CI environments | |
npm install -g wait-on # Useful for waiting for services to be ready | |
- name: Create .env file | |
working-directory: ./Hyperswitch-React-Demo-App | |
run: | | |
touch .env | |
echo STATIC_DIR = ./dist >> .env | |
echo HYPERSWITCH_PUBLISHABLE_KEY = $HS_Pub_Key >> .env | |
echo HYPERSWITCH_SECRET_KEY = $HS_Sec_Key >> .env | |
echo PROFILE_ID = $HS_Prof_Id >> .env | |
echo HYPERSWITCH_SERVER_URL = $HS_Server_Url >> .env | |
echo HYPERSWITCH_CLIENT_URL = $HS_Client_Url >> .env | |
# Creates a .env file with environment variables needed for the application | |
- name: Build and start local server | |
run: | | |
npm run re:build | |
npm start & | |
echo "Hyperswitch Web started" | |
cd Hyperswitch-React-Demo-App | |
npm start & | |
echo "Demo App started" | |
# Wait for services to be ready | |
wait-on http://localhost:9050 http://localhost:3000 | |
timeout-minutes: 5 # Limit time for server startup | |
- name: Run Cypress Tests | |
uses: cypress-io/github-action@v6 | |
with: | |
working-directory: ./cypress-tests | |
# Add command to specify which tests to run | |
command: npx cypress run --browser chrome | |
env: | |
CYPRESS_HYPERSWITCH_PUBLISHABLE_KEY: ${{ secrets.HYPERSWITCH_PUBLISHABLE_KEY }} | |
CYPRESS_HYPERSWITCH_SECRET_KEY: ${{ secrets.HYPERSWITCH_SECRET_KEY }} | |
# Cypress-specific timeout configurations | |
CYPRESS_DEFAULT_COMMAND_TIMEOUT: 10000 # 10 seconds | |
CYPRESS_PAGE_LOAD_TIMEOUT: 10000 | |
CYPRESS_REQUEST_TIMEOUT: 10000 | |
CYPRESS_SCRIPT_TIMEOUT: 10000 | |
- name: Upload Cypress Screenshots | |
uses: actions/upload-artifact@v4 | |
if: failure() | |
with: | |
name: cypress-screenshots | |
path: ./cypress-tests/cypress/screenshots | |
- name: Upload Cypress Videos | |
uses: actions/upload-artifact@v4 | |
if: always() | |
with: | |
name: cypress-videos | |
path: ./cypress-tests/cypress/videos | |
# Optional: Add a retry job if the first run fails | |
retry-cypress: | |
needs: cypress | |
if: failure() | |
runs-on: ubuntu-latest | |
steps: | |
- name: Retry Cypress Tests | |
uses: actions/checkout@v4 | |
with: | |
repository: ${{ github.repository }} | |
ref: ${{ github.ref }} | |
- name: Rerun Cypress Tests | |
uses: cypress-io/github-action@v6 | |
with: | |
working-directory: ./cypress-tests | |
command: npx cypress run --browser chrome |