Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EPMRPP-89652 || Report the last error log to the test description for Vitest agent #16

Merged
merged 3 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
### Added
- ReportingApi with attachment support
- `extendTestDescriptionWithLastError` option to the RP config to be able to toggle the last error log attaching to the test description.

## [5.0.0] - 2024-02-15
### Added
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ The full list of available options presented below.
| restClientConfig | Optional | Not set | The object with `agent` property for configure [http(s)](https://nodejs.org/api/https.html#https_https_request_url_options_callback) client, may contain other client options eg. [`timeout`](https://github.com/reportportal/client-javascript#timeout-30000ms-on-axios-requests). <br/> Visit [client-javascript](https://github.com/reportportal/client-javascript) for more details. |
| launchUuidPrint | Optional | false | Whether to print the current launch UUID. |
| launchUuidPrintOutput | Optional | 'STDOUT' | Launch UUID printing output. Possible values: 'STDOUT', 'STDERR'. Works only if `launchUuidPrint` set to `true`. |
| extendTestDescriptionWithLastError | Optional | true | If set to `true` the latest error log will be attached to the test case description. |

The following options can be overridden using ENVIRONMENT variables:

Expand Down
1 change: 1 addition & 0 deletions src/models/configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,5 @@ export interface ReportPortalConfig extends ClientConfig {

// agent specific options
skippedIssue?: boolean;
extendTestDescriptionWithLastError?: boolean;
}
8 changes: 8 additions & 0 deletions src/reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export class RPReporter implements Reporter {

constructor(config: ReportPortalConfig) {
this.config = {
extendTestDescriptionWithLastError: true,
...config,
launchId: process.env.RP_LAUNCH_ID || config.launchId,
};
Expand Down Expand Up @@ -183,6 +184,13 @@ export class RPReporter implements Reporter {

if (taskResult?.errors?.length) {
const error = taskResult.errors[0];

if (this.config.extendTestDescriptionWithLastError) {
finishTestItemObj.description = (finishTestItemObj.description || '').concat(
`\n\`\`\`error\n${error.stack}\n\`\`\``,
);
}

const logRq: LogRQ = {
time: finishTestItemObj.endTime,
level: LOG_LEVELS.ERROR,
Expand Down
Loading