From 57d19c6c73bf906377673ba7933b6b53a73dbc13 Mon Sep 17 00:00:00 2001 From: Dmitrii Gridnev Date: Tue, 9 Jul 2024 13:13:18 +0200 Subject: [PATCH] feature: improve errors Improve the collecting information about failed tests. Now, the reporter will collect the stack trace and the error message from all errors for failed tests. --- qase-playwright/changelog.md | 7 +++++++ qase-playwright/package.json | 2 +- qase-playwright/src/reporter.ts | 23 ++++++++++++++++++----- 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/qase-playwright/changelog.md b/qase-playwright/changelog.md index 399f211e..3110b368 100644 --- a/qase-playwright/changelog.md +++ b/qase-playwright/changelog.md @@ -1,3 +1,10 @@ +# playwright-qase-reporter@2.0.6 + +## What's new + +Improve the collecting information about failed tests. +Now, the reporter will collect the stack trace and the error message from all errors for failed tests. + # playwright-qase-reporter@2.0.5 ## What's new diff --git a/qase-playwright/package.json b/qase-playwright/package.json index 4748140c..f1e84a5e 100644 --- a/qase-playwright/package.json +++ b/qase-playwright/package.json @@ -1,6 +1,6 @@ { "name": "playwright-qase-reporter", - "version": "2.0.5", + "version": "2.0.6", "description": "Qase TMS Playwright Reporter", "main": "./dist/index.js", "types": "./dist/index.d.ts", diff --git a/qase-playwright/src/reporter.ts b/qase-playwright/src/reporter.ts index 7ce39bc2..52281f4d 100644 --- a/qase-playwright/src/reporter.ts +++ b/qase-playwright/src/reporter.ts @@ -210,14 +210,27 @@ export class PlaywrightQaseReporter implements Reporter { } /** - * @param {TestError} testError + * @param {TestError[]} testErrors * @returns {Error} * @private */ - private static transformError(testError: TestError): Error { - const error = new Error(testError.message); + private static transformError(testErrors: TestError[]): Error { - error.stack = testError.stack ?? ''; + let message = ''; + for (const error of testErrors) { + if (error.message == undefined) { + continue; + } + message += error.message + '\n\n'; + } + + const error = new Error(message); + for (const error of testErrors) { + if (error.stack == undefined) { + continue; + } + error.stack += error.stack + '\n\n'; + } return error; } @@ -318,7 +331,7 @@ export class PlaywrightQaseReporter implements Reporter { return; } - const error = result.error ? PlaywrightQaseReporter.transformError(result.error) : null; + const error = result.error ? PlaywrightQaseReporter.transformError(result.errors) : null; const suites = testCaseMetadata.suite != '' ? [testCaseMetadata.suite] : PlaywrightQaseReporter.transformSuiteTitle(test); let message: string | null = null;