Reputation: 51
I'm trying to prepare a test that's capable to wait more than 20s for a response. But even if i try to set timeout on wait() function, it doesn't respect the option.
cy.visit('http:site')
cy.intercept('GET', '**/slowEndpoint**').as('slow')
cy.get('[data-qa-id="btnCallsEndpoint"]').click()
cy.wait('@slow', {timeout: 60000}) // should do the magic
//This button is in another page, so for that, i CANT put the timeout option in here
cy.get('[data-qa-id="btnAvailableAfterResponseOK"]').click()
Am i doing something wrong?
Upvotes: 1
Views: 1272
Reputation: 51
I figure it out, the problem is that i'm putting the cy.intercept() on beforeEach(), for that it doesn't work. If i put right before the wait(), inside the test, it works!
Don't know if this is the right behaviour, but i'll change here.
Upvotes: 2
Reputation: 148
It might be that the intercept is being registered too late. Try putting the intercept before the visit command. This might do the trick. Everything else looks good to me.
Upvotes: 0