Skip to content

Commit

Permalink
feature: improve the collecting information about failed tests
Browse files Browse the repository at this point in the history
All error messages and traces will be saved in the stacktrace field.
  • Loading branch information
gibiw committed Jul 9, 2024
1 parent ffdec16 commit 447d3fc
Show file tree
Hide file tree
Showing 16 changed files with 53 additions and 44 deletions.
7 changes: 7 additions & 0 deletions qase-cucumberjs/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-cucumberjs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cucumberjs-qase-reporter",
"version": "2.0.0",
"version": "2.0.1",
"description": "Qase TMS CucumberJS Reporter",
"homepage": "https://github.com/qase-tms/qase-javascript",
"main": "./dist/index.js",
Expand Down
2 changes: 1 addition & 1 deletion qase-cucumberjs/src/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ export class Storage {
start_time: null,
end_time: null,
duration: Math.abs(testCase.timestamp.seconds - tcs.timestamp.seconds),
stacktrace: error?.stack ?? null,
stacktrace: error?.message ?? null,
thread: null,
},
fields: metadata.fields,
Expand Down
7 changes: 7 additions & 0 deletions qase-cypress/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-cypress/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cypress-qase-reporter",
"version": "2.0.2",
"version": "2.0.3",
"description": "Qase Cypress Reporter",
"homepage": "https://github.com/qase-tms/qase-javascript",
"sideEffects": false,
Expand Down
2 changes: 1 addition & 1 deletion qase-cypress/src/reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ export class CypressQaseReporter extends reporters.Base {
attachments: attachments ?? [],
author: null,
fields: {},
message: test.err?.message ?? null,
message: null,
muted: false,
params: {},
relations: relations,
Expand Down
7 changes: 7 additions & 0 deletions qase-jest/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-jest/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jest-qase-reporter",
"version": "2.0.1",
"version": "2.0.2",
"description": "Qase TMS Jest Reporter",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion qase-jest/src/reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ export class JestQaseReporter implements Reporter {
thread: null,
},
fields: {},
message: error?.message ?? null,
message: null,
muted: false,
params: {},
relations: this.getRelations(filePath, ancestorTitles),
Expand Down
7 changes: 7 additions & 0 deletions qase-newman/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-newman/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "newman-reporter-qase",
"version": "2.0.0",
"version": "2.0.1",
"description": "Qase TMS Newman Reporter",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
Expand Down
1 change: 0 additions & 1 deletion qase-newman/src/reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ export class NewmanQaseReporter {

pendingResult.execution.status = TestStatusEnum.failed;
pendingResult.execution.stacktrace = err.stack ?? null;
pendingResult.message = err.message;
}
},
);
Expand Down
31 changes: 5 additions & 26 deletions qase-playwright/src/reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,28 +211,19 @@ export class PlaywrightQaseReporter implements Reporter {

/**
* @param {TestError[]} testErrors
* @returns {Error}
* @returns {string}
* @private
*/
private static transformError(testErrors: TestError[]): Error {

private static transformError(testErrors: TestError[]): string {
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';
message += error.stack + '\n\n';
}

return error;
return message;
}

/**
Expand Down Expand Up @@ -339,16 +330,6 @@ export class PlaywrightQaseReporter implements Reporter {
message = testCaseMetadata.comment;
}

if (error) {
if (message) {
message += '\n\n';
} else {
message = '';
}

message += error.message;
}

const testResult: TestResultType = {
attachments: testCaseMetadata.attachments,
author: null,
Expand All @@ -357,9 +338,7 @@ export class PlaywrightQaseReporter implements Reporter {
start_time: result.startTime.valueOf() / 1000,
end_time: null,
duration: result.duration,
stacktrace: error === null ?
null : error.stack === undefined ?
null : error.stack,
stacktrace: error,
thread: result.parallelIndex.toString(),
},
fields: testCaseMetadata.fields,
Expand Down
7 changes: 7 additions & 0 deletions qase-testcafe/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-testcafe/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "testcafe-reporter-qase",
"version": "2.0.0",
"version": "2.0.1",
"description": "Qase TMS TestCafe Reporter",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
Expand Down
14 changes: 5 additions & 9 deletions qase-testcafe/src/reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,10 @@ export class TestcafeQaseReporter {

/**
* @param {TestRunErrorFormattableAdapterType[]} errors
* @returns {Error}
* @returns {string}
* @private
*/
private static transformErrors(errors: TestRunErrorFormattableAdapterType[]): Error {
private static transformErrors(errors: TestRunErrorFormattableAdapterType[]): string {
const [errorMessages, errorStacks] = errors.reduce<[string[], string[]]>(
([messages, stacks], error) => {
const stack =
Expand All @@ -113,11 +113,7 @@ export class TestcafeQaseReporter {
[[], []],
);

const error = new Error(errorMessages.join('\n\n'));

error.stack = errorStacks.join('\n\n');

return error;
return errorMessages.join('\n\n') + '\n\n' + errorStacks.join('\n\n');
}

/**
Expand Down Expand Up @@ -192,11 +188,11 @@ export class TestcafeQaseReporter {
start_time: null,
end_time: null,
duration: testRunInfo.durationMs,
stacktrace: error.stack ?? null,
stacktrace: error,
thread: null,
},
fields: metadata[metadataEnum.fields],
message: error.message,
message: null,
muted: false,
params: metadata[metadataEnum.parameters],
relations: {
Expand Down

0 comments on commit 447d3fc

Please sign in to comment.