Skip to content

Commit

Permalink
EPMRPP-89652 || Report the last error log to the test description for…
Browse files Browse the repository at this point in the history
… Vitest agent (#16)
  • Loading branch information
AliakseiLiasnitski authored Apr 29, 2024
1 parent 783e54c commit f500050
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 0 deletions.
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

0 comments on commit f500050

Please sign in to comment.