Skip to content

Commit

Permalink
test: timeout correction
Browse files Browse the repository at this point in the history
  • Loading branch information
aritro2002 committed Dec 9, 2024
1 parent 1d935c0 commit 2f37cfa
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 10 deletions.
61 changes: 53 additions & 8 deletions .github/workflows/run-automation-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ 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"
Expand All @@ -23,14 +24,15 @@ jobs:
# Checks out the repository so that the workflow can access the code

- name: Set up Node.js
uses: actions/setup-node@v3
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 install
# Installs the necessary npm dependencies for the project
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
Expand All @@ -46,16 +48,59 @@ jobs:

- name: Build and start local server
run: |
npm run re:build && npm start &
echo "Hyperswitch Web started" && cd Hyperswitch-React-Demo-App && npm start &
npm run re:build
npm start &
echo "Hyperswitch Web started"
cd Hyperswitch-React-Demo-App
npm start &
echo "Demo App started"
# Builds the project and starts both the Hyperswitch Web and Demo App servers in the background
# 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
- 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 }}
# Runs Cypress tests located in the specified directory
# 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
8 changes: 6 additions & 2 deletions cypress-tests/cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,9 @@ module.exports = defineConfig({
e2e: {
baseUrl: "http://localhost:9050",
},
retries: { runMode: 1, openMode: 1 },
});
retries: { runMode: 2, openMode: 1 },
defaultCommandTimeout: 10000,
pageLoadTimeout: 10000,
requestTimeout: 10000,
responseTimeout: 10000,
});

0 comments on commit 2f37cfa

Please sign in to comment.