wdio-reportportal-reporter
Advanced tools
Comparing version 0.0.3 to 0.0.4
'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 @@ } |
HTTP dependency
Supply chain riskContains a dependency which resolves to a remote HTTP URL which could be used to inject untrusted code and reduce overall package reliability.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
15
494
23436
1
1
- Removed@babel/runtime@7.26.7(transitive)
- Removedaxios@0.18.1(transitive)
- Removedaxios-retry@3.9.1(transitive)
- Removedbalanced-match@1.0.2(transitive)
- Removedbrace-expansion@1.1.11(transitive)
- Removedconcat-map@0.0.1(transitive)
- Removedfollow-redirects@1.5.10(transitive)
- Removedfs.realpath@1.0.0(transitive)
- Removedglob@7.2.3(transitive)
- Removedinflight@1.0.6(transitive)
- Removedinherits@2.0.4(transitive)
- Removedis-buffer@2.0.5(transitive)
- Removedis-retry-allowed@2.2.0(transitive)
- Removedminimatch@3.1.2(transitive)
- Removedonce@1.4.0(transitive)
- Removedpath-is-absolute@1.0.1(transitive)
- Removedregenerator-runtime@0.14.1(transitive)
- Removedreportportal-client@5.5.0(transitive)
- Removeduniqid@5.4.0(transitive)
- Removedwrappy@1.0.2(transitive)
Updatedreportportal-client@https://github.com/reportportal/client-javascript.git#b09e49b