mysterious-belgium-25713
09/23/2022, 7:40 PMjs
import './commands'
var isFailed = false;
var failedTitle;
Cypress.on('fail', (error, runnable) => {
failedTitle = runnable.fullTitle();
isFailed = true
throw error
})
afterEach(function() {
if(isFailed){
cy.screenshot(`The failed test is ${failedTitle}`,{capture: "fullPage"})
isFailed = false
}
})
This gives you 2 screenshots one the default when it failed.
And the second a screenshot that makes a fullpage with the failed test title.
Hope this will help you