Skip to content

Commit

Permalink
EPMRPP-92471 || Fix launch finishing for tests annotated with .skip (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
AmsterGet authored Jul 1, 2024
1 parent c6b9ed5 commit 7c105d0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 19 deletions.
11 changes: 7 additions & 4 deletions lib/reporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ class Reporter {
this.currentTestTempInfo = null;
this.suitesStackTempInfo = [];
this.suiteTestCaseIds = new Map();
// TODO: use a single Map for test info
this.pendingTestsIds = [];
// TODO: use a single Map for suite info
this.suiteStatuses = new Map();
this.cucumberSteps = new Map();
}
Expand Down Expand Up @@ -150,6 +152,7 @@ class Reporter {
};
if (this.pendingTestsIds.includes(test.id)) {
this.testEnd(test);
this.pendingTestsIds = this.pendingTestsIds.filter((id) => id !== test.id);
}
}

Expand All @@ -165,10 +168,9 @@ class Reporter {
}

testEnd(test) {
let testId = this.testItemIds.get(test.id);
const testId = this.testItemIds.get(test.id);
if (!testId) {
this.testStart(test);
testId = this.testItemIds.get(test.id);
return;
}
this.sendLogOnFinishFailedItem(test, testId);
this.finishFailedStep(test);
Expand All @@ -180,12 +182,13 @@ class Reporter {
promiseErrorHandler(finishTestItemPromise, 'Fail to finish test');
this.resetCurrentTestFinishParams();
this.currentTestTempInfo = null;
this.testItemIds.delete(test.id);
}

testPending(test) {
// if test has not been started, save test.id to finish in testStart().
// if testStarted() has been called, call testEnd() directly.
if (this.testItemIds.get(test.id) != null) {
if (this.testItemIds.get(test.id)) {
this.testEnd(test);
} else {
this.pendingTestsIds.push(test.id);
Expand Down
1 change: 1 addition & 0 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ const getSuiteEndObject = (suite) => ({
endTime: new Date().valueOf(),
});

// TODO: update/split to not return the redundant and confusing data for items start
const getTestInfo = (test, testFileName, status, err) => ({
id: test.id,
status: status || (test.state === 'pending' ? testItemStatuses.SKIPPED : test.state),
Expand Down
15 changes: 0 additions & 15 deletions test/reporter.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -297,21 +297,6 @@ describe('reporter script', () => {
expect(spyFinishTestItem).toHaveBeenCalledWith('tempTestItemId', expectedTestFinishObj);
});

it('end not started test: should call testStart', function () {
const spyTestStart = jest.spyOn(reporter, 'testStart');
const testInfoObject = {
id: 'testId',
title: 'test name',
status: 'failed',
parentId: 'suiteId',
err: 'error message',
};

reporter.testEnd(testInfoObject);

expect(spyTestStart).toHaveBeenCalled();
});

it('end failed test: should call sendLog on test fail', function () {
const spySendLogOnFinishFailedItem = jest.spyOn(reporter, 'sendLogOnFinishFailedItem');
const testInfoObject = {
Expand Down

0 comments on commit 7c105d0

Please sign in to comment.