Feature / question
E2E testing dapp using web3. The app uses web3 which is polling a port regularly. This filling up test run logs on cypress UI. XHR events are all around while running and it's logging even after successful finish it makes really hard to follow tests. It also makes the UI very unresponsive.
Would be great to silence / mute certain XHR calls in the log.
There might a way (e.g. overriding event? but I couldn't figure out..)
Run any dapp in cypress then the logs will be filled
N/A
You can already do this.
It's documented here: https://on.cypress.io/server#Syntax
And to change the global defaults you can do it here: https://on.cypress.io/cypress-server#Notes
thank you, it works like a charm :)
@szerintedmi Can you please let me know a sample code of how did you silence the XHR Request on the log. I am not running the API but UI Tests, so not sure what to do in this case
@moinuddin14 Did you try to place the code below in cypress/support/index.js
Cypress.Server.defaults({
delay: 500,
force404: false,
whitelist: (xhr) => {
// handle custom logic for whitelisting
return true;
}
})
Whitelisting all the XHR requests will break the stubbing feature, because a whitelisted request will be invisible to the Cypress.Server
. You probably don't want to do that. See #7362.
How can we do this in cypress 5.1.0
Please help
Cypress.Server.defaults({
delay: 500,
force404: false,
whitelist: (xhr) => {
// handle custom logic for whitelisting
return true;
}
})
this code doesn't work in Cypress 5.1.0
and the using ignore in the same place is throwing an error.
Cypress.Server.defaults({
delay: 500,
force404: false,
whitelist: (xhr) => {
// handle custom logic for whitelisting
return true;
}
})this code doesn't work in Cypress 5.1.0
and the using ignore in the same place is throwing an error.
5.0.0 | Renamed聽whitelist聽option to聽ignore
try this
Cypress.Server.defaults({
delay: 500,
force404: false,
ignore: (xhr) => {
// handle custom logic for whitelisting
return true;
}
})
It's working. Thank you.
Most helpful comment
You can already do this.
It's documented here: https://on.cypress.io/server#Syntax
And to change the global defaults you can do it here: https://on.cypress.io/cypress-server#Notes