https://cypress.io logo
Hi. Could someone tell me how to make `cy.intercep...
# e2e-testing
b
Hi. Could someone tell me how to make
cy.intercept
work for external calls? It seems to be a very common thing to happen on any web app but yet I failed to find a working example or workaround. Here's a failing snippet I had prepared:
Copy code
describe('Intercept external request', () => {
  it('Can intercept external resource request', () => {
    cy.intercept({
      url: 'https://github.githubassets.com/images/modules/site/home/globe/flag.obj',
    }).as('extCall');
    cy.intercept({
      url: 'https://api.funcaptcha.com/*',
    }).as('extCall2');

    cy.visit('https://github.com');
    // This works
    cy.wait('@extCall').its('response.statusCode').should('eq', 200);

    // eslint-disable-next-line cypress/no-unnecessary-waiting
    cy.wait(5000);

    cy.contains('Sign up').click();
    // The following will fail
    cy.wait('@extCall2').its('response.statusCode').should('eq', 200);

    // eslint-disable-next-line cypress/no-unnecessary-waiting
    cy.wait(5000);
  });
});
Is this me just using it incorrectly or is this a bug? Help will be very appreciated 🙏 PS:
chromeWebSecurity: false
didn't help.