https://cypress.io logo
Hiding third party XHR in logs when testing
# i-need-help
b
Is it possible to hide these XHR requests made by zendesk/pinterest, etc, in the logs when testing for better visibility?
p
b
Nice thanks!
g
Hey @best-flower-17510 in Cypress v12 the api logs in the command log became really obnoxiously long. If there is one thing everyone complains about Cypress this is the top one. Just freaking hide them, especially the ones without an intercept
b
The team has confirmed that we have a resolution coming very...very soon 😀
l
Alternatively, you can add this to your
e2e.js
file, with your own domains:
Copy code
js
// Hide some request domains from the log
// See: https://gist.github.com/simenbrekken/3d2248f9e50c1143bf9dbe02e67f5399?permalink_comment_id=4190114#gistcomment-4190114
const originalLog = Cypress.log
const domainsToHide = ['sandbox.secure.checkout.visa.com']
Cypress.log = function (opts, ...other) {
  const isXhr = ['xhr'].includes(opts.displayName)
  const isOther = ['other'].includes(opts.displayName)
  const xhrMatch =
    (isXhr || isOther) &&
    domainsToHide.find((domain) => opts.url.includes(domain))
  if (xhrMatch) return

  return originalLog(opts, ...other)
}
g
code running in the browser can be changed and overwritten so easily