Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
wdio-reportportal-reporter
Advanced tools
A WebdriverIO v5 reporter plugin to report results to Report Portal(http://reportportal.io/). For v4 version see this branch
The easiest way is to keep wdio-reportportal-reporter
and wdio-reportportal-service
as a devDependency in your package.json
.
{
"devDependencies": {
"wdio-reportportal-reporter": "5.2.2",
"wdio-reportportal-service": "5.2.2"
}
}
Instructions on how to install WebdriverIO
can be found here.
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: {
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",
tags: ["tags", "for", "launch"],
},
reportSeleniumCommands: false,
autoAttachScreenshots: false,
seleniumCommandsLogLevel: 'debug',
screenshotsLogLevel: 'info',
parseTagsFromTestTitle: false,
};
exports.config = {
// ...
services: [[RpService, {}]],
reporters: [[reportportal, conf]],
// ...
};
See readme in wdio-rp-integration-demoC
Api methods can be accessed using:
const reporter = require('wdio-reportportal-reporter')
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 contenttype
(String, optional) – attachment MIME-type, image/png
by defaultreporter.sendLogToTest(test, level, message)
- send log to specific test.
test
(object) - test object from afterTest\afterStep
wdio hooklevel
(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 hooklevel
(string) - log level. Values ['trace', 'debug', 'info', 'warn', 'error'].name
(string)– file name.content
(String) – attachment contenttype
(string, optional) – attachment MIME-type, image/png
by defaultPay 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 reporter = 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);
reporter.sendFileToTest(test, 'info', filename, fs.readFileSync(outputFile));
}
}
...
WDIO Cucumber "5.14.3+" Example:
const reporter = 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');
reporter.sendFileToTest(failureObject, 'error', "screnshot.png", attachment);
}
}
...
}
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 rpVersion = 5; // or 4 for Report Portal v4
const protocol = 'http:';
const hostname = 'example.com';
const port = ':8080'; // or empty string for default 80/443 ports
const link = await RpService.getLaunchUrlByParams(rpVersion, protocol, hostname, port, config);
console.log(`Report portal link ${link}`)
}
...
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
This project is licensed under the MIT License - see the LICENSE.md file for details
FAQs
A WebdriverIO v6 plugin. Report results to Report Portal.
The npm package wdio-reportportal-reporter receives a total of 19,990 weekly downloads. As such, wdio-reportportal-reporter popularity was classified as popular.
We found that wdio-reportportal-reporter demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.