I'm trying to overwrite an existing command in Cypress.io. I'm looking to log() a route response's status
& the route's url
to extend the functionality of the built-in route(). Unfortunately, I get this message The route undefined had a undefined status code.
in the console
. Note, I'm using the browser's console
momentarily. Eventually, I'll use the log()
built-in method. This is what I have tried so far:
cypress/support/commands.js
Cypress.Commands.overwrite('route', (originalFn, response) => {
console.log(`The route ${response.url} had a ${response.status} status code.`);
return originalFn(response);
});
Update:
I'm getting the route now, but I still don't get response
or status
. This is my current code:
Cypress.Commands.overwrite('route', (originalFn, url, response) => {
console.log(`The route ${url} had ${response} status code`);
return originalFn(url, response);
});