Does a Cypress retry (caused by a failure) trigger Cypress.on("fail")?

Viewed 51

Does a Cypress retry (caused by a failure) trigger Cypress.on("fail")? With failed Cypress tests getting re-tried up to 3 times, does each instance of a failing test get trigger Cypress.on("fail"), or just once when the test is finally deemed a “failure” after being re-tried 3 times?

Which one of the situations below would be correct?

A)

Test fails 1st time -> Cypress.on("fail")

Test fails 2nd time -> Cypress.on("fail")

Test passes on the 3rd try

B)

Test fails 1st time

Test fails 2nd time

Test passes on the 3rd try -> Cypress.on("fail")

C)

Test fails 1st, 2nd, and 3rd time -> Cypress.on("fail")

1 Answers

I would say it's called each time, but you can check it out yourself

Cypress.on('fail', (error, runnable) => {
  console.log('fail')
})

Also take a look at the runnable parameter, I think it has a test property that has properties related to the retry status

Cypress.on('fail', (error, runnable) => {
  console.log('fail', runnable.test)
})
Related