We encountered a situation where we needed to assert that a spinner was displayed during a request using the following code:
The code functioned properly in Cypress 6.4.0
cy.intercept({
url: '*',
onRequest: () => {
cy.get('[data-testid=spinner-loading-indicator]')
.should('exist')
},
});
However, in Cypress 7.5.0, onRequest
is no longer accepted.
The closest alternative we found was:
cy.intercept('*', (req) => {
req.on('before:response', (res) => {
cy.get('[data-testid=spinner-loading-indicator]').should('exist')
})
})
This solution resulted in an error due to Cypress not allowing promises in this context (cy.get() returning a promise)
Has anyone encountered a similar issue, and if so, how was it resolved?