Skip to content

Commit

Permalink
Merge pull request #95 from reportportal/develop
Browse files Browse the repository at this point in the history
Release 5.0.3
  • Loading branch information
AmsterGet authored Jul 18, 2023
2 parents 8022d60 + d718218 commit 53d6d53
Show file tree
Hide file tree
Showing 21 changed files with 4,707 additions and 4,746 deletions.
3 changes: 2 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
"no-invalid-this": 0,
"prefer-object-spread": 0,
"no-console": 0,
"func-names": 0
"func-names": 0,
"default-param-last": 0
},
"overrides": [{
"files": ["*.spec.js"],
Expand Down
14 changes: 6 additions & 8 deletions .github/workflows/CI-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,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@v1
uses: actions/setup-node@v3
with:
node-version: 12.x
- name: Clean install of node dependencies
run: npm ci
node-version: 18
- name: Install of node dependencies
run: npm install
- name: Run lint
run: npm run lint
- name: Run tests
run: npm test
- name: Check coverage
- name: Run tests and check coverage
run: npm run test:coverage
28 changes: 13 additions & 15 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,33 +22,31 @@ 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@v1
uses: actions/setup-node@v3
with:
node-version: 12.x
- name: Clean install of node dependencies
run: npm ci
node-version: 18
- name: Install of node dependencies
run: npm install
- name: Run lint
run: npm run lint
- name: Run tests
run: npm test
- name: Check coverage
- name: Run tests and check coverage
run: npm run test:coverage

publish-to-npm-and-gpr:
needs: build
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@v1
uses: actions/setup-node@v3
with:
node-version: 12.x
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 @@ -57,9 +55,9 @@ jobs:
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }}
- name: Set up Node.js
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
node-version: 12.x
node-version: 18
registry-url: 'https://npm.pkg.github.com'
scope: '@reportportal'
- name: Publish to GPR
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
### Changed
- `token` configuration option was renamed to `apiKey` to maintain common convention.
- `@reportportal/client-javascript` bumped to version `5.0.12`.

## [5.0.2] - 2022-12-12
### Fixed
Expand Down
52 changes: 30 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
# Mocha reporter for EPAM report portal
This is mocha runtime reporter for the [Report Portal](https://github.com/reportportal/reportportal).
# @reportportal/agent-js-mocha

Agent to integrate Mocha with ReportPortal.
* More about [Mocha](https://mochajs.org/)
* More about [ReportPortal](http://reportportal.io/)

It was designed to work with mocha programmatically, in order to be able to parametrize each test run.

## Installation steps:
## Installation

```cmd
npm install @reportportal/agent-js-mocha
npm install --save-dev @reportportal/agent-js-mocha
```

## How to use:
Fill reporterOptions in Mocha configuration.
```javascript
const Mocha = require("mocha");
let mochaMain = new Mocha({
const mochaMain = new Mocha({
reporter: '@reportportal/agent-js-mocha',
reporterOptions: {
"token": "00000000-0000-0000-0000-000000000000",
"apiKey": "reportportalApiKey",
"endpoint": "https://your.reportportal.server/api/v1",
"project": "YourReportPortalProjectName",
"launch": "YourLauncherName",
Expand All @@ -40,7 +43,7 @@ module.exports = {
reporter: '@reportportal/agent-js-mocha',
'reporter-option':[
'endpoint=https://your.reportportal.server/api/v1',
'token=00000000-0000-0000-0000-000000000000',
'apiKey=reportportalApiKey',
'launch=YourLauncherName',
'project=YourReportPortalProjectName',
'attributes=YourKey:YourValue;YourValue',
Expand All @@ -56,31 +59,36 @@ module.exports = {

### Options

Runs support following options:

| Parameter | Description |
| --------------------- | ----------------------------------------------------------------------------------------------------------------- |
| token | User's Report Portal token from which you want to send requests. It can be found on the profile page of this user.|
| endpoint | URL of your server. For example 'https://server:8080/api/v1'. |
| launch | Name of launch at creation. |
| project | The name of the project in which the launches will be created.
| mode | *Default: "default".* Results will be submitting to Launches tab<br> *"debug"* - Results will be submitting to Debug tab. |
| rerun | *Default: false.* Enable [rerun](https://github.com/reportportal/documentation/blob/master/src/md/src/DevGuides/rerun.md)|
| rerunOf | UUID of launch you want to rerun. If not specified, report portal will update the latest launch with the same name|
| reportHooks | *Default: false.* Determines report before and after hooks or not. |
| skippedIssue | *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.|
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 (values must be upper case). |
| 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. |
| reportHooks | Optional | false | Determines report before and after hooks or not. |
| 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. |

### Additional reporting functionality

The agent provides an API to extend the functionality of Mocha.

Import the PublicReportingAPI as shown below to use additional reporting features.
Import the `PublicReportingAPI` as shown below to use additional reporting features.

```javascript
const PublicReportingAPI = require('@reportportal/agent-js-mocha/lib/publicReportingAPI');
```
#### Report logs and attachments
PublicReportingAPI provides the following methods for reporting logs into the current test/step.
`PublicReportingAPI` provides the following methods for reporting logs into the current test/step.

* log(*level*, *message* , *file*). Reports *message* and optional *file* with specified log *level* as a log of the current test. If called outside of the test, reports message as a log of the current suite.<br/>
*level* shoud be equal to one the following values: *TRACE*, *DEBUG*, *INFO*, *WARN*, *ERROR*, *FATAL*.<br/>
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.0.2
5.0.3-SNAPSHOT
1 change: 0 additions & 1 deletion lib/mochaReporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ class ReportportalAgent extends Mocha.reporters.Base {
const attributes = parseAttributes(this.options.reporterOptions.attributes);
const launchAttributes = (attributes || []).concat(systemAttributes);
const { tempId, promise } = this.rpClient.startLaunch({
token: this.options.reporterOptions.token,
name: this.options.reporterOptions.launch,
startTime: this.rpClient.helpers.now(),
description: this.options.reporterOptions.description,
Expand Down
Loading

0 comments on commit 53d6d53

Please sign in to comment.