包详细信息

@reportportal/agent-js-codecept

reportportal19kMIT0.2.4

Reportportal plugin for Codecept JS tests

codeceptJS, codeceptjs, browserstack, codeceptjs-reportportal

自述文件

ReportPortal Agent for CodeceptJS

📋Beautiful enterprise-grade test reports integrated with CodeceptJS testing framework. This helpes you integrate the test results of CodeceptJS with ReportPortal

Based on CodeceptJS RPHelper by PeterNgTr.

ReportPortal Test

@reportportal/agent-js-codecept is a CodeceptJS plugin which can publish tests results on ReportPortal after execution.

When enabled this plugin sends information on test runs to ReportPortal server:

  • ✅status for failed and passed tests
  • 🔍step by step log
  • 🖼screenshots on failure are attached

Installation

npm i @reportportal/agent-js-codecept --save

Configuration

This plugin should be added in codecept.conf.js

Example:

{
  //...
   plugins: {
    reportportal: {
      enabled: true,
      require: '@reportportal/agent-js-codecept',
      token: 'YOUR_TOKEN',
      endpoint: 'http://localhost:8080/api/v1',
      launchName: 'local launch',
    }
  //...
}

To use this plugin you need to provide the following info:

  • token: which can be found by navigating to the user profile page, clicking the username drop-down in the right header and selecting the "Profile" > "UUID" – is a unique user identifier. UUID is used in automated test configuration files for a user authentication instead of a password. It will allow you to post data, without logging it in the UI.
  • endpoint: your reportportal host + api/v1 for instance: http://localhost:8080/api/v1
  • launchName: the launch name you want, if not provided, the suite title will be used
  • projectName: the project that you created in the reportportal UI
  • launchDescription: (optional) the description of your launch, if not provided, the description will be empty
  • launchAttributes: (optional) the attributes of your launch, if not provided, the attributes will be empty
  • debug: (optional) to turn on the debug for reportportal
  • rerun: (optional) to enable rerun
  • rerunOf: (optional) UUID of launch you want to rerun. If not specified, report portal will update the latest launch with the same name.

Public API

Add Log Message

You can send logs to ReportPortal to current step / test by accessing this plugin from your code:

const reportPortal = codeceptjs.container.plugins('reportportal');
reportPortal.addLog({
  level: 'debug',
  message: 'your message'
});

To send attachment, use second parameter:

const reportPortal = codeceptjs.container.plugins('reportportal');
reportPortal.addLog({
  level: 'debug',
  message: 'your message'
}, {
  name: 'screenshot.png',
  type: 'image/png',
  content: fs.readFileSync('output/screenshot.png')
});

See sendLog method of ReportPortal JavaScript Client for more oprtions.

Get Report URL

Once report is posted a special reportportal.result event is created.

You can use it to pass URL of a report into other plugins. For instance, you can use it to send Slack or Email notifications including a link to a report.

// inside your custom plugin:
event.dispatcher.on('reportportal.result', (result) => {
  // use result.link as URL to report
  console.log('Report was published at', result.link);
})

Todo

  • [ ] Support run-workers command to aggregate all tests under one launch.

Debugging Plugin

To debug this plugin run script enabing DEBUG env variable:

DEBUG="codeceptjs:reportportal"  npx codeceptjs run

更新日志

Changelog

[1.1.9] - 2019-11-13

  • remove unused lib

[1.1.8] - 2019-11-13

  • fix screenshots/browser logs are not added in reportportal

[1.1.7] - 2019-11-12

  • make codacy happy

[1.1.6] - 2019-11-12

  • fix error on empty scenarios
  • some improvements/minor fixes

[1.1.5] - 2019-11-11

  • improvement on scenario with empty step

[1.1.4] - 2019-11-08

  • fix the launch is always passed

[1.1.3] - 2019-11-08

  • fix codacy issues
  • add badges

[1.1.2] - 2019-11-08

  • move README.md to root so that npm can read it

[1.1.1] - 2019-11-08

  • fix README.md

[1.1.0] - 2019-11-08

Added

  • changelog file
  • move Markdown files to .github
  • bump reportportal-client to 5.2.3
  • add eslint
  • combine all feature tests into a launch instead of each feature will stay in a launch