Removing an intercept in Cypress

Viewed 660

I have an intercept that serves up a stubbed json response like this:

    cy.intercept('GET', '**/api/v1/myroute/*', { fixture: 'myData.json' }).as('myAlias')

Is there a way I can remove this intercept halfway through a test somehow? I was hoping to delete the alias so the xhr request doesn't get intercepted at all. Thanks!

1 Answers

OK, figured this one out. Simply do this:

cy.intercept('GET', '**/api/v1/myroute/*', (req) => {
  req.continue()
});
Related