Skip to content

Commit

Permalink
change skipped tests handling logic
Browse files Browse the repository at this point in the history
  • Loading branch information
epszaw committed Aug 22, 2023
1 parent a74ead7 commit 6419ab2
Showing 1 changed file with 9 additions and 19 deletions.
28 changes: 9 additions & 19 deletions packages/allure-hermione/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ const hostname = os.hostname();

const hermioneAllureReporter = (hermione: Hermione, opts: AllureReportOptions) => {
const { ALLURE_REPORTER_DEV_MODE } = process.env;
const loadedTests: Map<string, Hermione.Test> = new Map();
const runningTests: Map<string, AllureTest> = new Map();
const runtime = new AllureRuntime({
resultsDir: "allure-results",
Expand Down Expand Up @@ -239,11 +238,17 @@ const hermioneAllureReporter = (hermione: Hermione, opts: AllureReportOptions) =
});
});
hermione.on(hermione.events.AFTER_TESTS_READ, (collection) => {
// cache all the tests to handle skipped tests in future
// handle all skipped (pending) tests
collection.eachTest((test) => {
const testId = getTestId(test);
if (!test.pending) {
return;
}

const currentTest = createAllureTest(test);

loadedTests.set(testId(), test);
currentTest.status = Status.SKIPPED;
currentTest.stage = Stage.FINISHED;
currentTest.endTest();
});
});
hermione.on(hermione.events.TEST_BEGIN, (test) => {
Expand Down Expand Up @@ -290,23 +295,8 @@ const hermioneAllureReporter = (hermione: Hermione, opts: AllureReportOptions) =
currentTest.calculateHistoryId();
currentTest.stage = Stage.FINISHED;
currentTest.endTest(Date.now());
loadedTests.delete(testId());
runningTests.delete(testId());
});
hermione.on(hermione.events.END, () => {
// all tests have been finished
if (loadedTests.size === 0) {
return;
}

loadedTests.forEach((test) => {
const currentTest = createAllureTest(test);

currentTest.status = Status.SKIPPED;
currentTest.stage = Stage.FINISHED;
currentTest.endTest();
});
});

// it needs for tests because we need to read runtime writer data redefined in hermione config
// eslint-disable-next-line
Expand Down

0 comments on commit 6419ab2

Please sign in to comment.