Skip to content

Commit

Permalink
fix: history id for tests failed in before all, address #200
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleksandr Shevtsov authored and Shelex committed Apr 4, 2023
1 parent 9e9ac85 commit 9ba39f3
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions reporter/allure-cypress/AllureReporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,25 @@ module.exports = class AllureReporter {
}

this.currentTest.fullName = test.title;
this.currentTest.historyId = crypto
.MD5(test.fullTitle())

// handle history hash match for tests failed in before all hook
if (test.state === Status.FAILED && test.hookName) {
logger.allure(
`found test failed in hook, fixing title to match history id`
);
// "hooktype" hook: hookname for "testname"
// grab just "testname" to consider for calculating historyid hash
const match = test.title.match(/\"(.*?)\"/g).pop();

// set title if match does contain test title
test.title =
match === test.hookName ? test.title : match.replace(/\"/g, '');
}

this.currentTest.info.historyId = crypto
.MD5(test.title)
.toString(crypto.enc.Hex);
this.currentTest.stage = Stage.RUNNING;
this.currentTest.info.stage = Stage.RUNNING;
this.addPackageLabel();

if (
Expand Down

0 comments on commit 9ba39f3

Please sign in to comment.