0

I'm building a CI with github action and I want to run a login attempt test, there are two specs, the first makes the attempt (where it blocks for 10 minutes for the next attempt) and the other checks if it has already reached the established limit . It turns out that I'm testing with a 30-second workflow sleep and still the blocking message doesn't appear, but rather the normal login attempt message.

When I run Cypress headless on my machine it blocks the email, but in github action it doesn't block at any time. Does it have to do with the IP? or something like this?

`login_test_part1: name: Login Cypress run with delay - Part 1 runs-on: ubuntu-22.04 steps: - name: Checkout uses: actions/checkout@v4

  - name: Run login Cypress test - part 1
    uses: cypress-io/github-action@v6
    with:
      record: true
      parallel: false
      group: "Login Test 1"
      spec: "cypress/e2e/loginTentativa_1.cy.js"
    env:
      CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
   
  - name: Upload email and timestamp artifacts
    uses: actions/upload-artifact@v3
    with:
      name: login-artifacts
      path: cypress/upload/

  - name: Wait for 10 minutes
    run: sleep 3

login_test_part2: name: Login Cypress run with delay - Part 2 runs-on: ubuntu-22.04 needs: login_test_part1 steps: - name: Checkout uses: actions/checkout@v4

  - name: Download email and timestamp artifacts
    uses: actions/download-artifact@v3
    with:
      name: login-artifacts
      path: cypress/upload/

  - name: Run login Cypress test - part 2
    uses: cypress-io/github-action@v6
    with:
      record: true
      parallel: false
      group: "Login Test 2"
      spec: "cypress/e2e/loginTentativa_2.cy.js"
    env:
      CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}`

I expect it to crash on the fifth attempt when the test is run by github action workflow

1 Answer 1

2

It might be better to combine loginTentativa_1.cy.js and loginTentativa_2.cy.js into one test.

It appears together they test one feature, and using cy.clock() and cy.tick() commands you can simulate a 10 minute wait without actually waiting 10 minutes.

This is depending on the app using setTimeout() or setInterval() to expire the login credentials.

The general documentation is here Stubs Spies and Clocks, plus command documentaion cy.clock() and cy.tick()

I would expect the test to look something like this

cy.clock()
cy.visit('/')

// perform login

cy.tick(600_000)  // ms

// check login status

Not the answer you're looking for? Browse other questions tagged or ask your own question.