All Projects → BorisOsipov → wdio-reportportal-reporter

BorisOsipov / wdio-reportportal-reporter

Licence: MIT license
A WebdriverIO plugin. Report results to Report Portal.

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to wdio-reportportal-reporter

webdriverio-testing-library
🕷️ Simple and complete WebdriverIO DOM testing utilities that encourage good testing practices.
Stars: ✭ 13 (-40.91%)
Mutual labels:  webdriverio
mugshot
Framework independent visual testing library
Stars: ✭ 126 (+472.73%)
Mutual labels:  webdriverio
serenity-reportportal-integration
Serenity TAF integration with Report Portal
Stars: ✭ 21 (-4.55%)
Mutual labels:  reportportal
Codeceptjs
Supercharged End 2 End Testing Framework for NodeJS
Stars: ✭ 3,592 (+16227.27%)
Mutual labels:  webdriverio
fullstack-typescript
A demo project of a full stack typescript application
Stars: ✭ 28 (+27.27%)
Mutual labels:  webdriverio
frontend testing
Repository containing sample code used in a Frontend Testing workshop
Stars: ✭ 14 (-36.36%)
Mutual labels:  webdriverio
gulp-webdriver
gulp-webdriver is a gulp plugin to run selenium tests with the WebdriverIO testrunner
Stars: ✭ 77 (+250%)
Mutual labels:  webdriverio
webdriverio-zap-proxy
Demo - how to easily build security testing for Web App, using Zap and Glue
Stars: ✭ 58 (+163.64%)
Mutual labels:  webdriverio
my-react-todolist
A guide to TDD a React/Redux TodoList App
Stars: ✭ 22 (+0%)
Mutual labels:  webdriverio
service-api
Report portal. Main API Service
Stars: ✭ 35 (+59.09%)
Mutual labels:  reportportal
Webdriverio
Next-gen browser and mobile automation test framework for Node.js
Stars: ✭ 7,214 (+32690.91%)
Mutual labels:  webdriverio
wdio-starter-kit
Boilerplate repo for quick set up of WebdriverIO test scripts with TravisCI, Sauce Labs and Visual Regression Testing
Stars: ✭ 31 (+40.91%)
Mutual labels:  webdriverio
kubernetes
Kubernetes/Helm configs for ReportPortal
Stars: ✭ 66 (+200%)
Mutual labels:  reportportal
web-automation
BDD tests with Cucumber, WebdriverIO and Docker Selenium
Stars: ✭ 114 (+418.18%)
Mutual labels:  webdriverio
ui-testing-book
Content for "The Web App Testing Guidebook"
Stars: ✭ 26 (+18.18%)
Mutual labels:  webdriverio
expect-webdriverio
WebdriverIO Assertion Library
Stars: ✭ 49 (+122.73%)
Mutual labels:  webdriverio
saloon
An E2E test seeder for enterprise web applications
Stars: ✭ 30 (+36.36%)
Mutual labels:  webdriverio
wdio-junit-reporter
A WebdriverIO v4 plugin. Report results in junit xml format.
Stars: ✭ 13 (-40.91%)
Mutual labels:  webdriverio
client-java
Asynchronous client for Java-based agents
Stars: ✭ 17 (-22.73%)
Mutual labels:  reportportal
agent-java-cucumber
Cucumber JVM version [1.0.0; 2.0.0) adapter
Stars: ✭ 21 (-4.55%)
Mutual labels:  reportportal

WDIO Report Portal Reporter

Greenkeeper badge

npm npm

A WebdriverIO reporter plugin to report results to Report Portal(http://reportportal.io/).

Installation

The easiest way is to keep wdio-reportportal-reporter and wdio-reportportal-service as a devDependency in your package.json.

{
  "devDependencies": {
    "wdio-reportportal-reporter": "^7.0.0",
    "wdio-reportportal-service": "^7.0.0"
  }
}

Instructions on how to install WebdriverIO can be found here.

Configuration

Configure the output directory in your wdio.conf.js file:

const reportportal = require('wdio-reportportal-reporter');
const RpService = require("wdio-reportportal-service");

const conf = {
  reportPortalClientConfig: { // report portal settings
    token: '00000000-0000-0000-0000-00000000000',
    endpoint: 'https://reportportal-url/api/v1',
    launch: 'launch_name',
    project: 'project_name',
    mode: 'DEFAULT',
    debug: false,
    description: "Launch description text",
    attributes: [{key:"tag", value: "foo"}],
    headers: {"foo": "bar"}, // optional headers for internal http client
    restClientConfig: { // axios like http client config - https://github.com/axios/axios#request-config
      proxy: {
        protocol: 'https',
        host: '127.0.0.1',
        port: 9000,
        auth: {
          username: 'mikeymike',
          password: 'rapunz3l'
        }
      },
      timeout: 60000
    }
  },
  reportSeleniumCommands: false, // add selenium commands to log
  seleniumCommandsLogLevel: 'debug', // log level for selenium commands
  autoAttachScreenshots: false, // automatically add screenshots
  screenshotsLogLevel: 'info', // log level for screenshots
  parseTagsFromTestTitle: false, // parse strings like `@foo` from titles and add to Report Portal
  cucumberNestedSteps: false, // report cucumber steps as Report Portal steps
  autoAttachCucumberFeatureToScenario: false, // requires cucumberNestedSteps to be true for use
  sanitizeErrorMessages: true, // strip color ascii characters from error stacktrace
  sauceLabOptions : {
    enabled: true, // automatically add SauseLab ID to rp tags.
    sldc: "US" // automatically add SauseLab region to rp tags.
  }
};

exports.config = {
  // ...
  services: [[RpService, {}]],
  reporters: [[reportportal, conf]],
  // ...
};

Additional API

Api methods can be accessed using:

const reporter = require('wdio-reportportal-reporter')

Methods description

  • reporter.addAttribute({key, value}) – add an attribute to current test.
    • key (string, optional) - attribute key. It must be non-empty string.
    • value (string, required)– attribute value. It must be non-empty string.
  • reporter.sendLog(level, message) – send log to current suite\test item.
    • level (string) - log level. Values ['trace', 'debug', 'info', 'warn', 'error'].
    • message (string)– log message content.
  • reporter.sendFile(level, name, content, [type]) – send file to current suite\test item.
    • level (string) - log level. Values ['trace', 'debug', 'info', 'warn', 'error'].
    • name (string)– file name.
    • content (string) – attachment content
    • type (string, optional) – attachment MIME-type, image/png by default
    • message (string)– log message content.
  • reporter.sendLogToTest(test, level, message) - send log to specific test.
    • test (object) - test object from afterTest\afterStep wdio hook
    • level (string) - log level. Values ['trace', 'debug', 'info', 'warn', 'error'].
    • message (string)– log message content.
  • reporter.sendFileToTest(test, level, name, content, [type]) – send file to to specific test.
    • test (object) - test object from afterTest\afterStep wdio hook
    • level (string) - log level. Values ['trace', 'debug', 'info', 'warn', 'error'].
    • name (string)– file name.
    • content (string) – attachment content
    • type (string, optional) – attachment MIME-type, image/png by default
    • message (string)– log message content.

Pay attention: sendLog\sendFile sends log to current running test item. It means if you send log without active test(e.g from hooks or on suite level) it will not be reported Report Portal UI.

Methods sendLogToTest\sendFileToTest are useful when you need to send screenshots or logs to the failed test item from wdio afterTest hook.

Mocha example:

const reportportal = require('wdio-reportportal-reporter');
const path = require('path');
const fs = require('fs');

exports.config = {
...
  afterTest(test) {
    if (test.passed === false) {
      const filename = "screnshot.png";
      const outputFile = path.join(__dirname, filename);
      browser.saveScreenshot(outputFile);
      reportportal.sendFileToTest(test, 'info', filename, fs.readFileSync(outputFile));
    }
  }
...

Jasmine example:

const reportportal = require('wdio-reportportal-reporter');
const path = require('path');
const fs = require('fs');

exports.config = {
...
  afterTest(test) {
    if (test.passed === false) {
      const filename = "screnshot.png";
      const outputFile = path.join(__dirname, filename);
      browser.saveScreenshot(outputFile);
      //!!
      Object.assign(test, {title: test.description}}
      reportportal.sendFileToTest(test, 'info', filename, fs.readFileSync(outputFile));
    }
  }
...

WDIO Cucumber "5.14.3+" Example:

const reportportal = require('wdio-reportportal-reporter');

exports.config = {
...
   afterStep: function (uri, feature, { error, result, duration, passed }, stepData, context) {
     if (!passed) {
        let failureObject = {};
        failureObject.type = 'afterStep';
        failureObject.error = error;
        failureObject.title = `${stepData.step.keyword}${stepData.step.text}`;
        const screenShot = global.browser.takeScreenshot();
        let attachment = Buffer.from(screenShot, 'base64');
        reportportal.sendFileToTest(failureObject, 'error', "screnshot.png", attachment);
    }
  }
...
}

Getting link to Report Portal UI launch page

const RpService = require("wdio-reportportal-service");
...
    onComplete: async function (_, config) {
        const link = await RpService.getLaunchUrl(config);
        console.log(`Report portal link ${link}`)
    }
...

or more complicated way

const RpService = require("wdio-reportportal-service");
...
    onComplete: async function (_, config) {
        const protocol = 'http:';
        const hostname = 'example.com';
        const port = ':8080'; // or empty string for default 80/443 ports
        const link = await RpService.getLaunchUrlByParams(protocol, hostname, port, config);
        console.log(`Report portal link ${link}`)
    }
...

Reporting test to existing launch

If you want report test to existing active launch you may pass it to reporter by environment variable REPORT_PORTAL_LAUNCH_ID You are responsible for finishing launch as well as starting such launch.

$ export REPORT_PORTAL_LAUNCH_ID=SomeLaunchId
$ npm run wdio

License

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].