Skip to content

Commit

Permalink
RPP-89217 Last Error Log (#141)
Browse files Browse the repository at this point in the history
  • Loading branch information
artsiomBandarenka authored Apr 30, 2024
1 parent ab4a741 commit b38fd7b
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 20 deletions.
39 changes: 20 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,25 +76,26 @@ In case you use the jest config section of `package.json`, add the following ent

The full list of available options presented below.

| Option | Necessity | Default | Description |
|-----------------------|------------|-----------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| apiKey | Required | | User's reportportal token from which you want to send requests. It can be found on the profile page of this user. |
| endpoint | Required | | URL of your server. For example 'https://server:8080/api/v1'. |
| launch | Required | | Name of launch at creation. |
| project | Required | | The name of the project in which the launches will be created. |
| attributes | Optional | [] | Launch attributes. |
| description | Optional | '' | Launch description. |
| rerun | Optional | false | Enable [rerun](https://reportportal.io/docs/dev-guides/RerunDevelopersGuide) |
| rerunOf | Optional | Not set | UUID of launch you want to rerun. If not specified, reportportal will update the latest launch with the same name |
| mode | Optional | 'DEFAULT' | Results will be submitted to Launches page <br/> *'DEBUG'* - Results will be submitted to Debug page. |
| skippedIssue | Optional | true | reportportal provides feature to mark skipped tests as not 'To Investigate'. <br/> Option could be equal boolean values: <br/> *true* - skipped tests considered as issues and will be marked as 'To Investigate' on reportportal. <br/> *false* - skipped tests will not be marked as 'To Investigate' on application. |
| debug | Optional | false | This flag allows seeing the logs of the client-javascript. Useful for debugging. |
| launchId | Optional | Not set | The _ID_ of an already existing launch. The launch must be in 'IN_PROGRESS' status while the tests are running. Please note that if this _ID_ is provided, the launch will not be finished at the end of the run and must be finished separately. |
| 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. |
| isLaunchMergeRequired | Optional | false | This flag determines whether to create temp files with the UUIDs of started launches and allow them to be merged using [`client-javascript`'s `mergeLaunches` method](https://github.com/reportportal/client-javascript#mergelaunches). Temp file format: `rplaunch-${launch_uuid}.tmp`. |
| 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`. |
| token | Deprecated | Not set | Use `apiKey` instead. |
| Option | Necessity | Default | Description |
|------------------------------------|------------|-----------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| apiKey | Required | | User's reportportal token from which you want to send requests. It can be found on the profile page of this user. |
| endpoint | Required | | URL of your server. For example 'https://server:8080/api/v1'. |
| launch | Required | | Name of launch at creation. |
| project | Required | | The name of the project in which the launches will be created. |
| attributes | Optional | [] | Launch attributes. |
| description | Optional | '' | Launch description. |
| rerun | Optional | false | Enable [rerun](https://reportportal.io/docs/dev-guides/RerunDevelopersGuide) |
| rerunOf | Optional | Not set | UUID of launch you want to rerun. If not specified, reportportal will update the latest launch with the same name |
| mode | Optional | 'DEFAULT' | Results will be submitted to Launches page <br/> *'DEBUG'* - Results will be submitted to Debug page. |
| skippedIssue | Optional | true | reportportal provides feature to mark skipped tests as not 'To Investigate'. <br/> Option could be equal boolean values: <br/> *true* - skipped tests considered as issues and will be marked as 'To Investigate' on reportportal. <br/> *false* - skipped tests will not be marked as 'To Investigate' on application. |
| debug | Optional | false | This flag allows seeing the logs of the client-javascript. Useful for debugging. |
| launchId | Optional | Not set | The _ID_ of an already existing launch. The launch must be in 'IN_PROGRESS' status while the tests are running. Please note that if this _ID_ is provided, the launch will not be finished at the end of the run and must be finished separately. |
| 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. |
| isLaunchMergeRequired | Optional | false | This flag determines whether to create temp files with the UUIDs of started launches and allow them to be merged using [`client-javascript`'s `mergeLaunches` method](https://github.com/reportportal/client-javascript#mergelaunches). Temp file format: `rplaunch-${launch_uuid}.tmp`. |
| 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. |
| token | Deprecated | Not set | Use `apiKey` instead. |

The following options can be overridden using ENVIRONMENT variables:

Expand Down
21 changes: 21 additions & 0 deletions __tests__/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,7 @@ describe('index script', () => {
const expectedFinishTestItemParameter = {
status: 'failed',
retry: false,
description: '```error\nerror message\n```',
};
reporter.tempStepId = 'tempStepId';

Expand All @@ -484,6 +485,26 @@ describe('index script', () => {
expectedFinishTestItemParameter,
);
});

test(
'finishTestItem should be called without description parameter ' +
'if extendTestDescriptionWithLastError is false',
() => {
const expectedFinishTestItemParameter = {
status: 'failed',
retry: false,
};
reporter.tempStepId = 'tempStepId';
reporter.reportOptions.extendTestDescriptionWithLastError = false;

reporter._finishFailedStep('error message', false);

expect(reporter.client.finishTestItem).toHaveBeenCalledWith(
'tempStepId',
expectedFinishTestItemParameter,
);
},
);
});

describe('_finishSkippedStep', () => {
Expand Down
6 changes: 5 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,11 @@ class JestReportPortal {

_finishFailedStep(failureMessage, isRetried) {
const status = testItemStatuses.FAILED;
const finishTestObj = { status, retry: isRetried };
const description =
this.reportOptions.extendTestDescriptionWithLastError === false
? null
: `\`\`\`error\n${stripAnsi(failureMessage)}\n\`\`\``;
const finishTestObj = { status, retry: isRetried, ...(description && { description }) };

this._sendLog(failureMessage);

Expand Down
1 change: 1 addition & 0 deletions utils/objectUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ const getAgentOptions = (options = {}) => {
isLaunchMergeRequired: options.isLaunchMergeRequired,
launchUuidPrint: options.launchUuidPrint,
launchUuidPrintOutput: options.launchUuidPrintOutput,
extendTestDescriptionWithLastError: options.extendTestDescriptionWithLastError,
};
};

Expand Down

0 comments on commit b38fd7b

Please sign in to comment.