question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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

Issue Analytics

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

github_iconTop GitHub Comments

39reactions
darina-techerycommented, Apr 25, 2019

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.

1reaction
darina-techerycommented, Apr 25, 2018

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Asserting Network Calls from Cypress Tests
This blog post shows how easy it is to confirm the network calls from the web app happen as expected. Note: you can...
Read more >
Cypress: Test non-XHR request caused by submitting POST ...
In some cases my application have to submit(not just after click submit button but programmatically) POST form and redirect to 3rd party server ......
Read more >
A Practical Guide to Intercepting Network Requests in Cypress
It's a very simple Vue.js app built with json-server - a single file json ... The previous command was only working with XHR...
Read more >
Part 27 - Intercept Network Requests (Both XHR and FETCH ...
In this video I've shown how to intercept the Network Requests with Cypress 1. Both XHR & FETCH Type Requests 2. SPY &...
Read more >
Cypress cy.intercept Problems - Gleb Bahmutov
visit command. By the time cy.intercept runs, the call is already in progress, and thus not intercepted. Cypress shows XHR calls by default...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found