Skip to content

Commit

Permalink
fix: remove cypress fail event, address #57
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleksandr Shevtsov committed Mar 22, 2021
1 parent 3c493e8 commit 72b15bc
Showing 1 changed file with 14 additions and 18 deletions.
32 changes: 14 additions & 18 deletions reporter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
});
}
}

Expand Down

0 comments on commit 72b15bc

Please sign in to comment.