New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

wdio-reportportal-reporter

Package Overview
Dependencies
Maintainers
1
Versions
57
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wdio-reportportal-reporter - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

build/utils.js

3

build/constants.js
'use strict';
/* eslint-disable object-curly-newline */
const testItemStatuses = { PASSED: 'passed', FAILED: 'failed', SKIPPED: 'skipped' };

@@ -7,5 +8,5 @@ const logLevels = {

};
const events = { RPLOG: 'rp:log', RPFILE: 'rp:file' };
const events = { RP_LOG: 'rp:log', RP_FILE: 'rp:file', RP_FAILED_LOG: 'rp:failedLog', RP_FAILED_FILE: 'rp:failedFile' };
const entityType = { SUITE: 'SUITE', TEST: 'STEP' };
module.exports = { testItemStatuses, logLevels, events, entityType };
'use strict';
var _promise = require('babel-runtime/core-js/promise');
var _promise2 = _interopRequireDefault(_promise);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const { EventEmitter } = require('events');
const { testItemStatuses, events, entityType } = require('./constants');
const ReportPortalClient = require('reportportal-client');
const { testItemStatuses, events, entityType } = require('./constants');
const { promiseErrorHandler, logger } = require('./utils');
const { PASSED, FAILED, SKIPPED } = testItemStatuses;

@@ -13,4 +21,8 @@

this.parentIds = {};
this.testStartRequestsPromises = {};
this.lastFailedTestRequestPromises = {};
this.config = config;
this.client = new ReportPortalClient(options);
const { tempId } = this.client.startLaunch({});
const { tempId, promise } = this.client.startLaunch({});
promiseErrorHandler(promise);
this.tempLaunchId = tempId;

@@ -34,8 +46,12 @@

// Rp events
this.on(events.RPLOG, this.sendLog.bind(this));
this.on(events.RPFILE, this.sendFile.bind(this));
this.on(events.RP_LOG, this.sendLog.bind(this));
this.on(events.RP_FILE, this.sendFile.bind(this));
this.on(events.RP_FAILED_LOG, this.sendLogToLastFailedItem.bind(this));
this.on(events.RP_FAILED_FILE, this.sendFileToLastFailedItem.bind(this));
const { epilogue } = baseReporter;
this.on('end', () => {
this.client.finishLaunch(this.tempLaunchId, {});
this.on('end', async () => {
const { promise: finishLaunchPromise } = this.client.finishLaunch(this.tempLaunchId, {});
promiseErrorHandler(finishLaunchPromise);
await finishLaunchPromise;
epilogue.call(baseReporter);

@@ -74,4 +90,4 @@ });

const { tempId } = this.client.startTestItem(suiteStartObj, this.tempLaunchId, this.getParentId(suite.cid));
const { tempId, promise } = this.client.startTestItem(suiteStartObj, this.tempLaunchId, this.getParentId(suite.cid));
promiseErrorHandler(promise);
this.addParentId(suite.cid, tempId);

@@ -81,3 +97,4 @@ }

suiteEnd(suite) {
this.client.finishTestItem(this.getParentId(suite.cid), {});
const { promise } = this.client.finishTestItem(this.getParentId(suite.cid), {});
promiseErrorHandler(promise);
this.clearParent(suite.cid);

@@ -98,4 +115,5 @@ }

const { tempId } = this.client.startTestItem(testStartObj, this.tempLaunchId, this.getParentId(test.cid));
const { tempId, promise } = this.client.startTestItem(testStartObj, this.tempLaunchId, this.getParentId(test.cid));
promiseErrorHandler(promise);
this.testStartRequestsPromises[test.cid] = promise;
this.addParentId(test.cid, tempId);

@@ -131,22 +149,60 @@ }

this.client.finishTestItem(parentId, finishTestObj);
const { promise } = this.client.finishTestItem(parentId, finishTestObj);
promiseErrorHandler(promise);
if (status === FAILED) {
this.lastFailedTestRequestPromises[test.cid] = this.testStartRequestsPromises[test.cid];
}
this.clearParent(test.cid);
delete this.testStartRequestsPromises[test.cid];
}
runnerCommand(command) {}
async sendLogToLastFailedItem({ cid, level, message }) {
if (!(await this.waitForFailedTest(cid, 2000, 10))) {
logger.warn('Attempt to send file to failed item fails. There is no failed test yet.');
return;
}
const rs = await this.lastFailedTestRequestPromises[cid];
start(event) {}
const saveLogRQ = {
item_id: rs.id,
level,
message,
time: this.client.helpers.now()
};
runnerResult(command) {}
const url = [this.client.baseURL, 'log'].join('/');
const promise = this.client.helpers.getServerResult(url, saveLogRQ, { headers: this.client.headers }, 'POST');
promiseErrorHandler(promise);
}
hookStart(hook) {}
// eslint-disable-next-line object-curly-newline
async sendFileToLastFailedItem({ cid, level, name, content, type = 'image/png' }) {
if (!(await this.waitForFailedTest(cid, 2000, 10))) {
logger.warn('Attempt to send log to failed item fails. There is no failed test yet.');
return;
}
const rs = await this.lastFailedTestRequestPromises[cid];
const saveLogRQ = {
item_id: rs.id,
level,
message: '',
time: this.client.helpers.now()
};
hookEnd(hook) {}
const promise = this.client.getRequestLogWithFile(saveLogRQ, { name, content, type });
promiseErrorHandler(promise);
}
sendLog({ cid, level, message }) {
const parentId = this.getParentId(cid);
this.client.sendLog(parentId, {
if (!parentId) {
return;
}
const { promise } = this.client.sendLog(parentId, {
message: String(message),
level
});
promiseErrorHandler(promise);
}

@@ -157,3 +213,7 @@

const parentId = this.getParentId(cid);
this.client.sendLog(parentId, { level }, { name, content, type });
if (!parentId) {
return;
}
const { promise } = this.client.sendLog(parentId, { level }, { name, content, type });
promiseErrorHandler(promise);
}

@@ -169,4 +229,18 @@

}
async waitForFailedTest(cid, time, count = 10) {
const interval = time / count;
while (count > 0) {
if (this.lastFailedTestRequestPromises[cid]) {
return true;
}
// eslint-disable-next-line no-await-in-loop
await new _promise2.default(resolve => setTimeout(resolve, interval));
// eslint-disable-next-line no-param-reassign
count -= 1;
}
return false;
}
}
module.exports = ReportPortalReporter;

@@ -16,3 +16,3 @@ 'use strict';

const sendLog = (level, message) => {
sendToReporter(events.RPLOG, { level, message });
sendToReporter(events.RP_LOG, { level, message });
};

@@ -22,5 +22,16 @@

// eslint-disable-next-line object-curly-newline
sendToReporter(events.RPFILE, { level, name, content, type });
sendToReporter(events.RP_FILE, { level, name, content, type });
};
module.exports = { sendLog, sendFile };
const sendLogToLastFailedTest = (level, message) => {
sendToReporter(events.RP_FAILED_LOG, { level, message });
};
const sendFileToLastFailedTest = (level, name, content, type = 'image/png') => {
// eslint-disable-next-line object-curly-newline
sendToReporter(events.RP_FAILED_FILE, { level, name, content, type });
};
module.exports = {
sendLog, sendFile, sendLogToLastFailedTest, sendFileToLastFailedTest
};

@@ -6,3 +6,3 @@ /* eslint-disable object-curly-newline */

};
const events = { RPLOG: 'rp:log', RPFILE: 'rp:file' };
const events = { RP_LOG: 'rp:log', RP_FILE: 'rp:file', RP_FAILED_LOG: 'rp:failedLog', RP_FAILED_FILE: 'rp:failedFile' };
const entityType = { SUITE: 'SUITE', TEST: 'STEP' };

@@ -9,0 +9,0 @@

const { EventEmitter } = require('events');
const { testItemStatuses, events, entityType } = require('./constants');
const ReportPortalClient = require('reportportal-client');
const { testItemStatuses, events, entityType } = require('./constants');
const { promiseErrorHandler, logger } = require('./utils');
const { PASSED, FAILED, SKIPPED } = testItemStatuses;

@@ -11,4 +13,8 @@

this.parentIds = {};
this.testStartRequestsPromises = {};
this.lastFailedTestRequestPromises = {};
this.config = config;
this.client = new ReportPortalClient(options);
const { tempId } = this.client.startLaunch({});
const { tempId, promise } = this.client.startLaunch({});
promiseErrorHandler(promise);
this.tempLaunchId = tempId;

@@ -32,8 +38,12 @@

// Rp events
this.on(events.RPLOG, ::this.sendLog);
this.on(events.RPFILE, ::this.sendFile);
this.on(events.RP_LOG, ::this.sendLog);
this.on(events.RP_FILE, ::this.sendFile);
this.on(events.RP_FAILED_LOG, ::this.sendLogToLastFailedItem);
this.on(events.RP_FAILED_FILE, ::this.sendFileToLastFailedItem);
const { epilogue } = baseReporter;
this.on('end', () => {
this.client.finishLaunch(this.tempLaunchId, {});
this.on('end', async () => {
const { promise: finishLaunchPromise } = this.client.finishLaunch(this.tempLaunchId, {});
promiseErrorHandler(finishLaunchPromise);
await finishLaunchPromise;
epilogue.call(baseReporter);

@@ -72,3 +82,3 @@ });

const { tempId } = this.client.startTestItem(
const { tempId, promise } = this.client.startTestItem(
suiteStartObj,

@@ -78,3 +88,3 @@ this.tempLaunchId,

);
promiseErrorHandler(promise);
this.addParentId(suite.cid, tempId);

@@ -84,3 +94,4 @@ }

suiteEnd(suite) {
this.client.finishTestItem(this.getParentId(suite.cid), {});
const { promise } = this.client.finishTestItem(this.getParentId(suite.cid), {});
promiseErrorHandler(promise);
this.clearParent(suite.cid);

@@ -101,3 +112,3 @@ }

const { tempId } = this.client.startTestItem(
const { tempId, promise } = this.client.startTestItem(
testStartObj,

@@ -107,3 +118,4 @@ this.tempLaunchId,

);
promiseErrorHandler(promise);
this.testStartRequestsPromises[test.cid] = promise;
this.addParentId(test.cid, tempId);

@@ -139,23 +151,48 @@ }

this.client.finishTestItem(parentId, finishTestObj);
this.clearParent(test.cid);
}
const { promise } = this.client.finishTestItem(parentId, finishTestObj);
promiseErrorHandler(promise);
runnerCommand(command) {
}
if (status === FAILED) {
this.lastFailedTestRequestPromises[test.cid] = this.testStartRequestsPromises[test.cid];
}
start(event) {
this.clearParent(test.cid);
delete this.testStartRequestsPromises[test.cid];
}
runnerResult(command) {
async sendLogToLastFailedItem({ cid, level, message }) {
if (!(await this.waitForFailedTest(cid, 2000, 10))) {
logger.warn('Attempt to send file to failed item fails. There is no failed test yet.');
return;
}
const rs = await this.lastFailedTestRequestPromises[cid];
}
const saveLogRQ = {
item_id: rs.id,
level,
message,
time: this.client.helpers.now(),
};
hookStart(hook) {
const url = [this.client.baseURL, 'log'].join('/');
const promise = this.client.helpers.getServerResult(url, saveLogRQ, { headers: this.client.headers }, 'POST');
promiseErrorHandler(promise);
}
hookEnd(hook) {
// eslint-disable-next-line object-curly-newline
async sendFileToLastFailedItem({ cid, level, name, content, type = 'image/png' }) {
if (!(await this.waitForFailedTest(cid, 2000, 10))) {
logger.warn('Attempt to send log to failed item fails. There is no failed test yet.');
return;
}
const rs = await this.lastFailedTestRequestPromises[cid];
const saveLogRQ = {
item_id: rs.id,
level,
message: '',
time: this.client.helpers.now(),
};
const promise = this.client.getRequestLogWithFile(saveLogRQ, { name, content, type });
promiseErrorHandler(promise);
}

@@ -165,6 +202,10 @@

const parentId = this.getParentId(cid);
this.client.sendLog(parentId, {
if (!parentId) {
return;
}
const { promise } = this.client.sendLog(parentId, {
message: String(message),
level,
});
promiseErrorHandler(promise);
}

@@ -175,3 +216,7 @@

const parentId = this.getParentId(cid);
this.client.sendLog(parentId, { level }, { name, content, type });
if (!parentId) {
return;
}
const { promise } = this.client.sendLog(parentId, { level }, { name, content, type });
promiseErrorHandler(promise);
}

@@ -187,4 +232,18 @@

}
async waitForFailedTest(cid, time, count = 10) {
const interval = time / count;
while (count > 0) {
if (this.lastFailedTestRequestPromises[cid]) {
return true;
}
// eslint-disable-next-line no-await-in-loop
await new Promise(resolve => setTimeout(resolve, interval));
// eslint-disable-next-line no-param-reassign
count -= 1;
}
return false;
}
}
module.exports = ReportPortalReporter;

@@ -8,3 +8,3 @@ const { events } = require('./constants');

const sendLog = (level, message) => {
sendToReporter(events.RPLOG, { level, message });
sendToReporter(events.RP_LOG, { level, message });
};

@@ -14,7 +14,17 @@

// eslint-disable-next-line object-curly-newline
sendToReporter(events.RPFILE, { level, name, content, type });
sendToReporter(events.RP_FILE, { level, name, content, type });
};
const sendLogToLastFailedTest = (level, message) => {
sendToReporter(events.RP_FAILED_LOG, { level, message });
};
module.exports = { sendLog, sendFile };
const sendFileToLastFailedTest = (level, name, content, type = 'image/png') => {
// eslint-disable-next-line object-curly-newline
sendToReporter(events.RP_FAILED_FILE, { level, name, content, type });
};
module.exports = {
sendLog, sendFile, sendLogToLastFailedTest, sendFileToLastFailedTest,
};
{
"name": "wdio-reportportal-reporter",
"version": "0.0.3",
"version": "0.0.4",
"description": "A WebdriverIO plugin. Report results to Report Portal.",

@@ -40,4 +40,4 @@ "main": "build/reporter.js",

"dependencies": {
"reportportal-client": "^5.1.0",
"babel-runtime": "^6.26.0"
"babel-runtime": "^6.26.0",
"reportportal-client": "https://github.com/reportportal/client-javascript.git#b09e49b"
},

@@ -47,5 +47,5 @@ "devDependencies": {

"babel-eslint": "^8.2.2",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-plugin-add-module-exports": "~0.2.1",
"babel-plugin-transform-function-bind": "^6.22.0",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-plugin-transform-runtime": "~6.23.0",

@@ -52,0 +52,0 @@ "babel-preset-env": "^1.6.1",

@@ -12,3 +12,3 @@ WDIO Report Portal Reporter

"devDependencies": {
"wdio-reportportal-reporter": "~0.0.1"
"wdio-reportportal-reporter": "~0.0.3"
}

@@ -15,0 +15,0 @@ }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc