I just wanted to mention that you can also very easily enable it for a single test by using the onBeforeLoad option on cy.visit.
In my case I had to rethrow the error with a setTimeout to not interrupt rendering that was currently going on.
function failOnConsoleError(win: Cypress.AUTWindow) {
win.console.error = (...args) => {
// since this is happening in the scope of the application
// rethrowing directly would cause more error messages
// we just delay it a bit, cypress will still log it as an uncaught error
// and causes the test to fail
setTimeout(() => {
throw new Error(args.join(', '))
}, 0);
}
}
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I just wanted to mention that you can also very easily enable it for a single test by using the
onBeforeLoad
option oncy.visit
.In my case I had to rethrow the error with a
setTimeout
to not interrupt rendering that was currently going on.