Skip
Skip

Reputation: 480

Cypress, test visiting a blocked link

I am trying to visit a link that is blocked for the user. I simply use the cy.visit() function to do this. My problem now is that the site, as it should, isn't loading the page but waits a whole minute until it fails. enter image description here

And I'm searching for a solution that doesn't include decreasing the pageLoadTimeout.

So is there a way to check if the page isn't loading (blocked)? I tried to solve it with .should() and {timouts} but haven't found a solution to my problem.

Upvotes: 0

Views: 613

Answers (1)

Leta Waldergrave
Leta Waldergrave

Reputation: 699

Try using request instead of visit,

cy.request('myurl', { failOnStatusCode: false})
  .then(response => {
    expect(response.status).not.to.eq(200)
  })

Upvotes: 1

Related Questions