Skip to content

Commit

Permalink
feature: improve errors
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
gibiw committed Jul 9, 2024
1 parent 0396549 commit 57d19c6
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
7 changes: 7 additions & 0 deletions qase-playwright/changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# [email protected]

## 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.

# [email protected]

## What's new
Expand Down
2 changes: 1 addition & 1 deletion qase-playwright/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
23 changes: 18 additions & 5 deletions qase-playwright/src/reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 57d19c6

Please sign in to comment.