diff --git a/reporter/index.js b/reporter/index.js index 4a6a6bf..72c27e8 100644 --- a/reporter/index.js +++ b/reporter/index.js @@ -82,6 +82,20 @@ class CypressAllureReporter { }) .on(EVENT_TEST_FAIL, (test, err) => { this.reporter.failTestCase(test, err); + + // add video to failed test case: + if (Cypress.config().video && this.reporter.currentTest) { + const videosFolderForAllure = Cypress.config() + .videosFolder.split(config.resultsPath) + .pop(); + const fileName = `${Cypress.spec.name}.mp4`; + + this.reporter.currentTest.addAttachment( + fileName, + 'video/mp4', + path.join(videosFolderForAllure, fileName) + ); + } }) .on(EVENT_TEST_PASS, (test) => { this.reporter.passTestCase(test); @@ -113,24 +127,6 @@ class CypressAllureReporter { config.shouldLogCypress && this.reporter.cyCommandEnd(command.attributes); }); - - Cypress.on('fail', (err) => { - config.shouldLogCypress && this.reporter.cyCommandsFinish(); - // add video to failed test case: - if (Cypress.config().video && this.reporter.currentTest) { - const videosFolderForAllure = Cypress.config() - .videosFolder.split(config.resultsPath) - .pop(); - const fileName = `${Cypress.spec.name}.mp4`; - - this.reporter.currentTest.addAttachment( - fileName, - 'video/mp4', - path.join(videosFolderForAllure, fileName) - ); - } - throw err; - }); } }