I have the intended functionality of canceling a pending XHR request in the application. I want to verify that the request is canceled after invoking the cancel action.
Right now I have this:
cy.intercept('GET', '**/request/**').as('Request');
invokeRequest();
invokeCancel();
cy.wait('@Request');
However, cypress is timing out on the cy.wait(). Is there a way to verify the request has been canceled?
You can use should and validate
it('should use wait value', () => {
cy.intercept('/todos').as('todos')
cy.visit('/')
cy.wait('@todos').should('include.all.keys', ['request', 'response'])
})
else you can use cy.route() instead of cy.intercept(). Refer this Has lot of examples: https://glebbahmutov.com/blog/cypress-intercept-problems/