# report-portal-js-agent

> ReportPortal Agent for Protractor-Cucumber-JS and Protractor

Latest version **0.0.9** (published 2018-12-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install report-portal-js-agent
pnpm add report-portal-js-agent
yarn add report-portal-js-agent
bun add report-portal-js-agent
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; large bundle; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.9 |
| Published | 2018-12-11 |
| First published | 2018-12-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 15 |
| Unpacked size | 52.1 MB |
| Known vulnerabilities | 0 (+2 in 2 direct dependencies) |
| Install scripts | no |
| GitHub stars | 8 |
| Author | minhhoang |
| Maintainers | hnminh |

## Links

- npm: https://www.npmjs.com/package/report-portal-js-agent
- Repository: https://github.com/toilatester/reportportal-javascript-agent
- Homepage: https://github.com/toilatester/reportportal-javascript-agent#readme
- Issues: https://github.com/toilatester/reportportal-javascript-agent/issues
- npm.io page: https://npm.io/package/report-portal-js-agent

## Dependencies (15)

- [chai](https://npm.io/package/chai.md) ^4.1.2
- [glob](https://npm.io/package/glob.md) ^7.1.2
- [http](https://npm.io/package/http.md) 0.0.0
- [log4js](https://npm.io/package/log4js.md) ^3.0.6
- [deasync](https://npm.io/package/deasync.md) ^0.1.14
- [jasmine](https://npm.io/package/jasmine.md) ^3.3.1
- [localize](https://npm.io/package/localize.md) ^0.4.7
- [commander](https://npm.io/package/commander.md) ^2.15.1
- [protractor](https://npm.io/package/protractor.md) ^5.4.1
- [json-concat](https://npm.io/package/json-concat.md) 0.0.1
- [is-generator](https://npm.io/package/is-generator.md) ^1.0.3
- [reportportal-client](https://npm.io/package/reportportal-client.md) ^5.1.0
- [cucumber-html-reporter](https://npm.io/package/cucumber-html-reporter.md) ^4.0.4
- [protractor-html-reporter](https://npm.io/package/protractor-html-reporter.md) ^1.3.2
- [multiple-cucumber-html-reporter](https://npm.io/package/multiple-cucumber-html-reporter.md) ^1.8.0

## Recent versions

- 0.0.9 (latest) — 2018-12-11
- 0.0.8 — 2018-12-11
- 0.0.7 — 2018-12-11
- 0.0.5 — 2018-12-11
- 0.0.4 — 2018-12-10
- 0.0.3 — 2018-12-10
- 0.0.2 — 2018-12-08

## README

# reportporal-javascript-agent

A Protractor and Prortactor-Cucumber-JS reporter plugin to report results to Report Portal(http://reportportal.io/).

## Sample ReportPortal for protractor

![](Demo.gif)

## Sample ReportPortal for protractor-cucumber-framework

![](CucumberDemo.gif)

## Installation

The easiest way is to keep `reportporal-javascript-agent` as a devDependency in your `package.json`.

```json
{
  "devDependencies": {
    "reportporal-javascript-agent": "~0.0.9"
  }
}
```

You can simple do it by:

```bash
npm install reportportal-javascript-agent --save-dev
```

Instructions on how to install `Protractor` can be found [here](http://www.protractortest.org/#/protractor-setup).
Instructions on how to install `Protractor-CucumberJS` can be found [here](https://github.com/protractor-cucumber-framework/protractor-cucumber-framework).

## Configuration for protractor

### Configuration for protractor config.js

sample reportportal.config.json file

```json
{
  "token": "f1d908c2-8ee9-4df7-8298-ca08ee28f04c",
  "endpoint": "http://localhost:6060/api/v1",
  "launch": "protractor-demo-refactor",
  "project": "demo-agent",
  "attachPicturesToLogs": true,
  "takeScreenshot": "onFailure",
  "debug": false
}
```

Configure the with the sample below in your protractor.config.js file:

```js
const {
  Log4jsReportPortal,
  ReportPortalAgent,
  JasmineAgent
} = require('../../lib');
const { Log4jsConfig } = require('./log4js');
const path = require('path');
const reportConfig = require('./report/reportportal.config.json');
const agent = new ReportPortalAgent(reportConfig);
const log4jsReportPortal = new Log4jsReportPortal(agent);
exports.configure = log4jsReportPortal.configure;
exports.config = {
  framework: 'jasmine',
  seleniumAddress: 'http://localhost:4444/wd/hub',
  specs: ['../spec-1.js', '../spec-2.js'],
  onPrepare: () => {
    jasmine.getEnv().addReporter(new JasmineAgent(agent));
  },
  beforeLaunch: () => {
    Log4jsConfig(path.join(__dirname, 'protractor.config.js'));
  },
  afterLaunch: async () => {}
};
```

## Configuration for protractor-cucumber-js

### Configuration for protractor config.js

sample reportportal.config.json file

```json
{
  "token": "f1d908c2-8ee9-4df7-8298-ca08ee28f04c",
  "endpoint": "http://localhost:6060/api/v1",
  "launch": "protractor-demo-refactor",
  "project": "demo-agent",
  "attachPicturesToLogs": true,
  "takeScreenshot": "onFailure",
  "debug": false
}
```

Configure the with the sample below in your protractor.cucumber.config.js file:

```js
const path = require('path');
const { getCapability } = require('./base/browser.config');
const { getCucumberOpts } = require('./cucumber/cucumber.config');
const { Log4jsConfig } = require('./log4js');
const reportConfig = require('./report/reportportal.config.json');
const {
  Report,
  combineRerunFiles,
  getOSInformation,
  extractCommandlineOptions,
  generateReportFolder,
  generateNestedFolder,
  Log4jsReportPortal,
  CucumberReportAgent
} = require('../../lib');
const cucumberAgent = new CucumberReportAgent(reportConfig);
const log4jsReportPortal = new Log4jsReportPortal(cucumberAgent.agent);
generateReportFolder();

global.__projectRoot = process.cwd();
generateNestedFolder(path.join(__projectRoot, 'rerun'));
const CURRENT_SESSION_INFO_FILE_NAME = './report/report.config.json';

global.REPORT_INFO = require(CURRENT_SESSION_INFO_FILE_NAME);

const startTime = new Date();

// Parse extra arguments which is sent from command line
// Note: Need to send exactly these option in command line
let { capability, isReRun, tags } = extractCommandlineOptions();

let config = {
  SELENIUM_PROMISE_MANAGER: false,

  seleniumAddress: 'http://localhost:4444/wd/hub',

  multiCapabilities: [getCapability(capability)],

  specs: ['../e2e/features/sample/*.feature'],

  framework: 'custom',

  frameworkPath: require.resolve('protractor-cucumber-framework'),

  cucumberOpts: getCucumberOpts(isReRun, tags),
  log4jsInstance: () => {
    return global.log4jsInstance;
  },
  beforeLaunch: function() {
    global.log4jsInstance = Log4jsConfig(
      path.join(__dirname, 'protractor.cucumber.config.js')
    );
  },

  onPrepare: async function() {
    // Get OS information and write into file
    await getOSInformation();
  },

  onComplete: async function() {
    let capability = await browser.getCapabilities();
    let info = global.REPORT_INFO;
    info.browser.name = capability.get('browserName');
    info.browser.version = capability.get('version');
    global.REPORT_INFO = info;
  },

  afterLaunch: async function() {
    // Merge all rerun file
    if (!isReRun) {
      combineRerunFiles(path.join(__projectRoot, 'rerun'));
    }

    // Generate report
    const completeTime = new Date();

    global.REPORT_INFO.startTime = startTime.toUTCString();
    global.REPORT_INFO.completeTime = completeTime.toUTCString();

    await Report.generate();
  }
};
exports.configure = log4jsReportPortal.configure;
exports.config = config;
exports.cucumberAgent = cucumberAgent;
```

### Configuration for protractor hook in cucumber

```js
'use strict';
const { setDefaultTimeout } = require('cucumber');
const { cucumberAgent } = require('../../config/protractor.cucumber.config');
const {
  CucumberReportHook
} = require('../../../lib/report-portal/cucumber-js');
const DEFAULT_TIMEOUT = 60000;

CucumberReportHook(cucumberAgent);
setDefaultTimeout(DEFAULT_TIMEOUT);
```

This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details

---
_Source: https://npm.io/package/report-portal-js-agent · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
