I am using retries in my Cypress test. Every time a test is retried, I want to perform an action (e.g. log details about the failure in a file).
I thought the command:retry from the catalog of events might be useful, but I am not sure what does the parameter mean and how can I use it.
CodePudding user response:
There is a cyclope plugin that may be covering what you are wanting to do with test failures. This plugin includes a utilty function savePageIfTestFailed, which you can call in an afterEach() inside your support/index.js file.
CodePudding user response:
You may find command:retry is a bit too granular, try the on fail event.
Cypress.on('fail', (error, runnable) => {
debugger
// take a look at the parameters
console.log('error', error.message)
console.log('runnable', runnable)
// for example
let currentTest = runnable.ctx.currentTest
let title = runnable.title
throw error // throw error to have test still fail
})
