From 9a4b9409e672e7a8c0676dd4d501650fb0b2d75d Mon Sep 17 00:00:00 2001 From: Aleksandr Zyabrev <40700843+oranje322@users.noreply.github.com> Date: Mon, 16 May 2022 16:39:19 +0300 Subject: [PATCH] EPMRPP-76797 || Tests steps fix (#47) Co-authored-by: Aleksandr Zyabrev --- src/reporter.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/reporter.ts b/src/reporter.ts index 00a3933..68ab886 100644 --- a/src/reporter.ts +++ b/src/reporter.ts @@ -388,14 +388,15 @@ export class RPReporter implements Reporter { const { includeTestSteps } = this.config; if (!includeTestSteps) return; const playwrightProjectName = test.parent.project().name; - const { id: testItemId } = this.findTestItem(this.testItems, test.title, playwrightProjectName); + const testItem = this.findTestItem(this.testItems, test.title, playwrightProjectName); + if (!testItem) return; const stepStartObj = { name: step.title, type: TEST_ITEM_TYPES.STEP, hasStats: false, startTime: this.client.helpers.now(), }; - const { tempId, promise } = this.client.startTestItem(stepStartObj, this.launchId, testItemId); + const { tempId, promise } = this.client.startTestItem(stepStartObj, this.launchId, testItem.id); this.addRequestToPromisesQueue(promise, 'Failed to start nested step.'); @@ -410,16 +411,17 @@ export class RPReporter implements Reporter { const { includeTestSteps } = this.config; if (!includeTestSteps) return; const playwrightProjectName = test.parent.project().name; - const { id } = this.findTestItem(this.nestedSteps, step.title, playwrightProjectName); + const testItem = this.findTestItem(this.nestedSteps, step.title, playwrightProjectName); + if (!testItem) return; const stepFinishObj = { status: step.error ? STATUSES.FAILED : STATUSES.PASSED, endTime: this.client.helpers.now(), }; - const { promise } = this.client.finishTestItem(id, stepFinishObj); + const { promise } = this.client.finishTestItem(testItem.id, stepFinishObj); this.addRequestToPromisesQueue(promise, 'Failed to finish nested step.'); - this.nestedSteps.delete(id); + this.nestedSteps.delete(testItem.id); } async onTestEnd(test: TestCase, result: TestResult): Promise {