cypress: Cypress is not capturing app XHR its only capturing 3rd party XHR calls

Current behavior:

Request(XHR) going to 3rd party is captured image Request going to our own api is not captured: image

Desired behavior:

Every XHR request on page load should be captured.

Steps to reproduce:

cy.visit('/');
          cy.get('select#users').select('ShootCoordinator')
          cy.get('input').click();
          cy.wait(2000)
          cy.get('.filter-callout.medium-text').contains('Filters')
          cy.visit('/asosstudio/');

Versions

Latest version of Cypress, latest version of Chrome and on Windows 7 OS

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 19 (6 by maintainers)

Most upvoted comments

I guess I know the answer. For some reason Cypress is not intercepting requests, when application uses Fetch API instead of XHR API.

Our application under test contains a lib which checks if browser knows about ‘fetch’ function. If not, it fallbacks to XHR-based requests. So, our solution was to “disable” fetch feature to cause this fallback. Our tests do the following:

(support/index.js)

Cypress.on('window:before:load', (win) => {
    win.fetch = null;
});

But in your case it might not work. Check with your developers if they use Fetch API, and if yes, ask if they can provide fallback to XHR API.

I can’t swear that your problem is of the same origin, but it looks exactly like ours to me.

It doesn’t. There is an open issue for that: https://github.com/cypress-io/cypress/issues/687