I have the following trackers blocked during Cypress tests. Cypress keeps on logging these urls in the test runner logs which is ugly and interferes with other useful log messages and assertions and increases scrolling/searching effort from the user.
Is there a way to disable logging of these urls in the test runner and console ?
//cypress.json
{ ...
"blockHosts": [
"*hsappstatic.net",
"*hubspot.com",
"*hs-banner.com",
"*usemessages.com",
"*newrelic.com",
"*nr-data.net",
"*datadoghq.com"
],
...
}
I was able to solve this by
//cypress/support/index.js
Cypress.Server.defaults({
ignore: xhr => {
return Cypress.config().blockHosts.some(blockedHost => // get blockHosts from cypress.json using Cypress.config()
Cypress.minimatch(new URL(xhr.url).host, blockedHost) // if current url matches any blockedHost item, return true
)
}
})
more details on https://github.com/cypress-io/cypress/discussions/16536
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With