so I’m writing this code in Cypress for finding broken links in a page
cy.get('a')
.each(($el, index, $list) => {
cy.request({
method: 'GET',
url: $el.prop('href'),
failOnStatusCode: false
})
.then((response) => {
if(response.status != 200){
cy.log($el.prop('href'))
}
})
})
Some links return 200 and that’s fine
Some links return 404 and that’s fine
Some links does not return any response
In this case test in cypress get terminated due to time out.
cy.request() timed out waiting 30000ms for a response from your server.
The request we sent was:
Method: GET
URL: https://www.facebook.com/xyz/
No response was received within the timeout.
I’d like to know how can I handle these links and log them for next steps.
Thank you
I would like to handle this situation