0

I'm practicing documentation example of intercept and then used wait alias of intercept but it's giving this error:

CypressError: Timed out retrying after 60000ms: `cy.wait()` timed out waiting `60000ms` for the 1st response to the route: `login`. No response ever occurred.

Mine code:

it("Should redirect to '/school-admin' if School Admin is authenticated", () => {
    cy.intercept('POST', `**/auth/local`).as('login')
    cy.visit('/')
    cy.get(textboxSelector).click()
    cy.wait('@login').then(interceptions => {
     expect(interceptions.response.statusCode).to.equal(200)
    })
  })

Also, tried following code but it the same result:

it("Should redirect to '/school-admin' if School Admin is authenticated", () => {
    cy.intercept('POST', `**/auth/local`).as('login')
    cy.visit('/')
    cy.get(textboxSelector)
      .click()
      .wait('@login').then(interceptions => {
         expect(interceptions.response.statusCode).to.equal(200)
    })
  })

Locally works perfect, but when GH actions starting work - tests were failing randomly but the error remains the same.

Cypress v9.6.0 but also tried with v10 as well

Uzair Khan
  • 109
  • 4
  • To reiterate, CI will be slower than your local so you should try your best to mimic CI behavior. You can either make sure the page is fully loaded by waiting on any requests sent by page load, check visibility of an element, or check visibility of your element before sending a click to it. – jjhelguero Nov 25 '22 at 16:20
  • when you're testing locally, are you using headless or ui? the ui mode sometimes gives different results then headless. Also consider that the GH runner might have different privileges and/or could be handling preflight differently – Daniel Nov 29 '22 at 18:06

0 Answers0