-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hide XHR requests from the command log #7362
Comments
I just found out this can be done easily programatically, see #1184 |
very interesting; thanks for flagging that issue |
Updated to v8.2.0 and development turned into nightmare: all useless server pollings are back in the UI, couldn't find anything in Did anyone find a way around it? |
This solution was working:
A couple versions ago, cant precise how many, but less than 2 months ago, it all appeared again. What can we do or how can we help to get this issue fixed? Version 8.4.0 |
So we still dont have any answer or next version, when it will be fixed? |
This is really frustrating. |
I ran into this problem myself and after a deep-dive into Cypress' logging internals I discovered a novel workaround, simply hide fetch/XHR command log entries with CSS. https://gist.github.com/simenbrekken/3d2248f9e50c1143bf9dbe02e67f5399 |
@simenbrekken This is working for me, thank you so much! |
I think I found the line that broke the xhr ignore option. See line 187 of packages/driver/src/cy/commands/xhr.js. The changes in the commit were included in the 8.2.0 release when it started breaking for @agelico. |
The workaround from @simenbrekken works great, but would love to see traction on the original issue, where XHR filtering seems completely broken. |
Cypress can leave all XHR requests in the Command Log but make them folded in only one line to be unfolded on necessity: this may be the fastest and the cheapest way to solve the issue. How do you think, folks? |
@avorvul-grove not the ideal, right? Because it would still use some of the space in the screen, it would still be bothering.. |
This worked for me: const origLog = Cypress.log
Cypress.log = function (opts, ...other) {
if (
opts.displayName === 'fetch' &&
opts.url.startsWith("https://example.com")
) {
return
}
return origLog(opts, ...other)
} |
Hello, where can i paste this code to disable xhr logs in cypress? |
You can include that in your support file or wrap it in a function so you can call it on demand for specific tests. Note, the code above only hides
|
Don't know if it changed in Cypress 10, which I'm using, but I had to change |
My version of the workaround above to mute the requests in the Cypress app:
const origLog = Cypress.log;
Cypress.log = function (opts, ...other) {
if (opts.displayName === 'script' || opts.name === 'request') {
return;
}
return origLog(opts, ...other);
}; Thank you, @cie! |
I've updated my original recipe to Cypress 10 and added proper TypeScript types: https://gist.github.com/simenbrekken-visma/e804c86fd6a23cc59b89913eabbf1d82 |
all this needs is an improvement in the runner UI like a button/area to filter what appears there or perhaps just the ability to 1-line them so you can at least see what's going on. We're running a dev server with a websocket and it's absolutely spammed with nothing and I can't see any tests whatsoever. A single graphql API call takes up 100% of the height of the sidebar |
Yeah, at my new job we're using a library that makes around ~200 XHR requests to handle zooming in-and-out of a 5GB image. I need @flotwig any chance of that happening? I was about to put a PR up, it's only a few lines, right? Edit
There's currently a bug when you pull down the user preferences pane because the Command Log will redraw itself. But... other than that, it works alright. |
@JessicaSachs message above as pasteable code... const isNoisy = (url:string) => url.includes('rum.browser-intake-datadoghq.com') || url.includes('ANOTHERURL.com');
Cypress.on('log:added', ev => {
if (ev.displayName === 'xhr' && isNoisy(ev.consoleProps.URL)) {
// @ts-expect-error -- you can modicy the types for this if you want.
const top$ = window.top?.Cypress.$Cypress.$;
top$('.command').last().hide();
}
}); I added this to the Any idea why it isn't working for me? |
Because it's a very brittle JQuery selector. You'll need to adjust it to your version of Cypress's command log in order to get it working until @flotwig is able to add a real solution for it. |
hey, is there any update on this? This would be really helpful us to improve cypress usage during the development, because several command log is generated with snapshot because of irrelevant api calls, which cause the cypress renderer to crash. |
Released in This comment thread has been locked. If you are still experiencing this issue after upgrading to |
Current behavior:
All XHR requests are printed to the command log, which can be distracting. There is no option to filter them. In #1184 it was mentioned this is possible by whitelisting requests with
Cypress.Server.defaults
, but that breaks stubbing.Desired behavior:
Having an option, to only log stubbed XHR requests to the command log.
Maybe the best fix would be not a config option, but a toggle on the test runner, that can hide these logs.
Test code to reproduce
Test any app that does network requests.
Versions
Any OS and version.
The text was updated successfully, but these errors were encountered: