Skip to content

Commit

Permalink
Merge pull request #128 from reportportal/develop
Browse files Browse the repository at this point in the history
Release 5.0.6
  • Loading branch information
AmsterGet authored Jul 18, 2023
2 parents 9522a58 + c10f04d commit dbd5341
Show file tree
Hide file tree
Showing 18 changed files with 2,951 additions and 2,931 deletions.
8 changes: 6 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"extends": "airbnb-base",
"extends": [
"airbnb-base",
"plugin:prettier/recommended",
"plugin:import/recommended"
],
"plugins": ["prettier"],
"globals": {
"expectAsync": true
},
Expand All @@ -8,7 +13,6 @@
"es6": true
},
"rules": {
"indent": ["error", 4],
"max-len": ["error", 120],
"valid-jsdoc": ["error", { "requireReturn": false }],
"consistent-return": 0,
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/CI-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: 18
- name: Clean install of node dependencies
run: npm ci
- name: Install of node dependencies
run: npm install
- name: Run lint
run: npm run lint
- name: Run tests and check coverage
Expand Down
18 changes: 9 additions & 9 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: 18
- name: Clean install of node dependencies
run: npm ci
- name: Install of node dependencies
run: npm install
- name: Run lint
run: npm run lint
- name: Run tests and check coverage
Expand All @@ -26,14 +26,14 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: 18
registry-url: 'https://registry.npmjs.org'
- name: Clean install of node dependencies
run: npm ci
- name: Install of node dependencies
run: npm install
- name: Publish to NPM
run: |
npm config set //registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN
Expand All @@ -42,7 +42,7 @@ jobs:
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }}
- name: Set up Node.js
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: 18
registry-url: 'https://npm.pkg.github.com'
Expand Down
6 changes: 6 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"arrowParens": "always",
"singleQuote": true,
"trailingComma": "all",
"printWidth": 100
}
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### Changed
- `token` configuration option was renamed to `apiKey` to maintain common convention.
- `@reportportal/client-javascript` bumped to version `5.0.12`.
- Readme file updated.

## [5.0.5] - 2023-03-16
### Added
Expand Down
215 changes: 90 additions & 125 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,49 @@
# @reportportal/agent-js-jest

A Jest reporter that uploads the results to a [ReportPortal](http://reportportal.io/) server.
Agent to integrate Jest with ReportPortal.
* More about [Jest](https://jestjs.io/)
* More about [ReportPortal](http://reportportal.io/)

## Installation

```shell
npm install --save-dev @reportportal/agent-js-jest
```

## Usage
## Configuration

In your jest config section of `package.json`, add the following entry:
**1.** Create `jest.config.js` file with reportportal configuration:
```javascript
module.exports = {
testRunner: 'jest-circus/runner',
testRegex: ['/__tests__/.*.spec.js?$'],
reporters: [
'default',
[
'@reportportal/agent-js-jest',
{
apiKey: 'reportportalApiKey',
endpoint: 'https://your.reportportal.server/api/v1',
project: 'Your reportportal project name',
launch: 'Your launch name',
attributes: [
{
key: 'key',
value: 'value',
},
{
value: 'value',
},
],
description: 'Your launch description',
}
]
],
...
};
```

In case you use the jest config section of `package.json`, add the following entry:

```JSON
{
Expand All @@ -20,146 +53,78 @@ In your jest config section of `package.json`, add the following entry:
"default",
["@reportportal/agent-js-jest",
{
"token": "00000000-0000-0000-0000-000000000000",
"token": "reportportalApiKey",
"endpoint": "https://your.reportportal.server/api/v1",
"project": "YourReportPortalProjectName",
"launch": "YourLauncherName",
"description": "YourDescription",
"logLaunchLink": true,
"project": "Your reportportal project name",
"launch": "Your launch name",
"attributes": [
{
"key": "YourKey",
"value": "YourValue"
"key": "key",
"value": "value"
},
{
"value": "YourValue"
},
"value": "value"
}
],
"restClientConfig": {
"timeout": 0
}
"description": "Your launch description"
}]
],
...
}
}
```

In case you use `jest.config.js`, you should add to it the following:

```javascript

module.exports = {
...
reporters: [
"default",
[
"@reportportal/agent-js-jest",
{
"token": "00000000-0000-0000-0000-000000000000",
"endpoint": "https://your.reportportal.server/api/v1",
"project": "YourReportPortalProjectName",
"launch": "YourLauncherName",
"description": "YourDescription",
"logLaunchLink": true,
"attributes": [
{
"key": "YourKey",
"value": "YourValue"
},
{
"value": "YourValue"
},
]
}
]
]
...
```
It's possible by using environment variables, it's important to mention that environment variables has precedence over `package.json` definition.
```shell
$ export RP_TOKEN=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
$ export RP_PROJECT_NAME=MY_AWESOME_PROJECT
$ export RP_ENDPOINT=MY_RP_ENDPOINT
$ export RP_LAUNCH=MY_COOL_LAUNCHER
$ export RP_DESCRIPTION=RP_DESCRIPTION
$ export RP_ATTRIBUTES=key:value,key:value,value
$ export RP_LAUNCH_ID=EXIST_LAUNCH_ID
$ export RP_MODE=DEBUG
```
This for your convenience in case you has a continuous job that run your tests and may post the results pointing to a different Report Portal definition of project, launcher name or tags.
## Disable the colors of test output:
In the Report Portal, the output of the test results may contain ANSI character set, this may be caused by the color setting in Jest. For version `"jest": "^24.8.0"`, use `jest --no-colors` command to disable the colors of test output.
## Used to report retry of test:
The agent supports of Retries.
Read more about [retries in jest](https://jestjs.io/docs/ru/jest-object#jestretrytimes).
## Rerun:
To report [rerun](https://github.com/reportportal/documentation/blob/master/src/md/src/DevGuides/rerun.md) to the report portal you need to specify the following options:
- rerun - to enable rerun
- rerunOf - UUID of launch you want to rerun. If not specified, report portal will update the latest launch with the same name
Example:
```json
"rerun": true,
"rerunOf": "f68f39f9-279c-4e8d-ac38-1216dffcc59c"
```
## Skipped issue:
_Default: true._ ReportPortal provides feature to mark skipped tests as not 'To Investigate' items on WS side.<br> Parameter could be equal boolean values:<br> _TRUE_ - skipped tests considered as issues and will be marked as 'To Investigate' on Report Portal.<br> _FALSE_ - skipped tests will not be marked as 'To Investigate' on application.
Example:
```json
"skippedIssue": false
```
## Launch mode:
Launch mode. Allowable values _DEFAULT_ (by default) or _DEBUG_.
Example:
```json
"mode": "DEBUG"
```
## Debug flag:
This flag allows seeing the logs of the client-javascript. Useful for debugging an agent.
Example:
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://github.com/reportportal/documentation/blob/master/src/md/src/DevGuides/rerun.md) |
| 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. |
| logLaunchLink | Optional | false | This flag allows print the URL of the Launch of the tests in console. |
| 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. |
| token | Deprecated | Not set | Use `apiKey` instead. |

The following options can be overridden using ENVIRONMENT variables:

| Option | ENV variable | Note |
|-------------|-----------------|----------------------------------------|
| apiKey | RP_API_KEY ||
| project | RP_PROJECT_NAME ||
| endpoint | RP_ENDPOINT ||
| launch | RP_LAUNCH | |
| attributes | RP_ATTRIBUTES | *Format:* key:value,key:value,value |
| description | RP_DESCRIPTION ||
| launchId | RP_LAUNCH_ID | |
| mode | RP_MODE ||
| token | RP_TOKEN | *deprecated* Use `RP_API_KEY` instead. |

This is for your convenience if you have a continuous job that runs your tests and may report results that point to a different reportportal project definition, launch name, or attributes.

**2.** Add script to `package.json` file:
```json
"debug": true
{
"scripts": {
"test": "jest --no-colors --detectOpenHandles --config ./jest.config.js"
}
}
```

## LogLaunchLink flag:
This flag allows print the URL of the Launch of the tests in console.
Example:
```json
"logLaunchLink": true
```
## Features

## REST Client config:
### Retries

Optional property.<br/>
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`.<br/>
Visit [client-javascript](https://github.com/reportportal/client-javascript) for more details.
The agent has support of retries.
Read more about [retries in jest](https://jestjs.io/ru/docs/jest-object#jestretrytimesnumretries-options).

# Copyright Notice

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.0.5
5.0.6-SNAPSHOT
Loading

0 comments on commit dbd5341

Please sign in to comment.