-
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
Is there an equivalent of cy.server({ignore: (xhr) => bool}) to disable logging, after moving to cy.intercept? #9358
Comments
Another reason one might want to disable request logging is to declutter the test reports. For example the cypress-allure-plugin by default creates a separate test step from every Cypress command ran which cause the resulting report to be unreadable if the application under test makes a ton of http calls under the hood. Ideally we should be able to turn the loggin on and off programmatically so that requests are logged when running tests in interactive mode but hidden when tests are ran on CI |
I'm looking for an equivalent of |
As far as I can tell, that's just the
All XHR's matching https://docs.cypress.io/api/commands/intercept.html#method-string |
Stop hiding fools |
If |
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 |
Did you find a solution for removing these request logs in the report with cypress-allure-plugin? |
Just to add to the original question: we are using SignalR and it is constantly checking the connection state, thus filling the logs with |
Oi! Be nice. |
One workaround that might apply to some cases: if you have access to change the code of the application under test, you can make use of window.Cypress For instance the app I am working on embeds Microsoft Clarity (among other 3rd party user tracking tools), which does frequent xhr posts (polluting Cypress's command log). So I changed the app to not include Clarity when running under Cypress. Technically in my case Clarity was being pulled in via Google Tag Manager which I also didn't care to have active while testing with Cypress so my solution was something like: |
The solution of @cie works nicely in the latest version It's also really easy to modify to your specific needs, simple example: const cypressLogOriginal = Cypress.log
const cypressLogDomainsHidden = ['fontawesome.com']
Cypress.log = function (opts, ...other) {
const logFetchIs = ['fetch'].includes(opts.displayName)
const logFetchDomainMatch = logFetchIs && cypressLogDomainsHidden.find((d) => opts.url.includes(d))
if (logFetchDomainMatch) return
return cypressLogOriginal(opts, ...other)
} |
that would really be useful as an option, I need that on cy.visit in some cases and definitely on cy.reload, the log is not workable right now |
Hey folks, I am consolidating this issue with #7362, please follow that issue for updates. |
Released in This comment thread has been locked. If you are still experiencing this issue after upgrading to |
What would you like?
I would like to continue to be able to disable logging of some routes after moving to
cy.intercept()
.Why is this needed?
A nice side-effect of calling
cy.server({ignore: (xhr) => bool})
to disable stubbing is that it also disables logging of matching routes. This helps decluttering the logs when we're running interactive tests.Examples are ping-pong requests with back-end server, webpack-dev-server's sockjs route, etc.
The text was updated successfully, but these errors were encountered: