reportportal-agent-cucumber
Advanced tools
Comparing version 0.1.1 to 1.0.0
@@ -39,40 +39,20 @@ const ReportPortalClient = require('reportportal-client') | ||
this.registerHandler('BeforeFeatures', (event, callback) => { | ||
if (!config.id) { | ||
reportportal.startLaunch({ | ||
name: config.launch, | ||
start_time: reportportal._now(), | ||
description: !config.description ? '' : config.description, | ||
tags: tagsConf | ||
}).then(id => { | ||
context.launchId = id.id | ||
callback() | ||
}) | ||
.catch(err => { | ||
console.log('Failed to start launch due to error', config.launch, err) | ||
callback() | ||
}) | ||
} else { | ||
context.launchId = config.id | ||
callback() | ||
} | ||
const startObj = config.id ? {id: config.id} : {} | ||
const launchObj = reportportal.startLaunch(startObj) | ||
context.launchId = launchObj.tempId | ||
callback() | ||
}) | ||
this.registerHandler('BeforeFeature', (event, callback) => { | ||
let featureUri = getEventUri(event.uri) | ||
let description = event.description ? reportportal._formatName(event.description) : featureUri | ||
let description = event.description ? event.description : featureUri | ||
let name = event.name | ||
reportportal.startTestItem({ | ||
name: reportportal._formatName(name), | ||
launch_id: context.launchId, | ||
start_time: reportportal._now(), | ||
let launchObj = reportportal.startTestItem({ | ||
name: name, | ||
type: 'SUITE', | ||
description: description, | ||
tags: event.tags ? event.tags.map(tag => tag.name) : [] | ||
}) | ||
.then(id => { | ||
context.featureId = id.id | ||
callback() | ||
}).catch(err => { | ||
console.log('Error occured on starting feature', err) | ||
callback() | ||
}) | ||
}, context.launchId) | ||
context.featureId = launchObj.tempId | ||
callback() | ||
}) | ||
@@ -92,18 +72,12 @@ this.registerHandler('BeforeScenario', (event, callback) => { | ||
reportportal.startTestItem({ | ||
name: reportportal._formatName(name), | ||
launch_id: context.launchId, | ||
start_time: reportportal._now(), | ||
let launchObj = reportportal.startTestItem({ | ||
name: name, | ||
type: 'TEST', | ||
description: description, | ||
tags: event.tags ? event.tags.map(tag => tag.name) : [] | ||
}, context.featureId) | ||
.then(testId => { | ||
context.scenarioId = testId.id | ||
callback() | ||
}).catch(err => { | ||
console.log('Error occured on starting scenario', err) | ||
callback() | ||
}) | ||
}, context.launchId, context.featureId) | ||
context.scenarioId = launchObj.tempId | ||
callback() | ||
}) | ||
this.registerHandler('BeforeStep', (event, callback) => { | ||
@@ -122,17 +96,10 @@ let args = [] | ||
} | ||
let name = event.name ? reportportal._formatName(`${event.keyword} ${event.name}`) : reportportal._formatName(event.keyword) | ||
reportportal.startTestItem({ | ||
let name = event.name ? `${event.keyword} ${event.name}` : event.keyword | ||
let launchObj = reportportal.startTestItem({ | ||
name: name, | ||
launch_id: context.launchId, | ||
start_time: reportportal._now(), | ||
type: 'STEP', | ||
description: args.length ? args.join('\n').trim() : '' | ||
}, context.scenarioId) | ||
.then(stepId => { | ||
context.stepId = stepId.id | ||
callback() | ||
}).catch(err => { | ||
console.log('Error occured on starting step', err) | ||
callback() | ||
}) | ||
}, context.featureId, context.scenarioId) | ||
context.stepId = launchObj.tempId | ||
callback() | ||
}) | ||
@@ -146,6 +113,3 @@ this.registerHandler('StepResult', (event, callback) => { | ||
let logMessage = getCuceJSON(attachment.data) | ||
let request = { | ||
item_id: context.stepId, | ||
time: reportportal._now() | ||
} | ||
let request = {} | ||
if (logMessage) { | ||
@@ -158,6 +122,3 @@ request.level = logMessage.level | ||
} | ||
reportportal.log(request) | ||
.catch(err => { | ||
console.log(err) | ||
}) | ||
reportportal.sendLog(context.stepId, request) | ||
break | ||
@@ -167,20 +128,16 @@ } | ||
let request = { | ||
item_id: context.stepId, | ||
time: reportportal._now(), | ||
level: context.stepStatus === 'passed' ? 'DEBUG' : 'ERROR' | ||
} | ||
let screenObj = { name: sceenshotName, | ||
type: 'image/png'} | ||
let pngObj = getCuceJSON(attachment.data) | ||
if (pngObj) { | ||
request.file = {name: pngObj.message} | ||
request.message = pngObj.message | ||
reportportal.sendFile([request], pngObj.message, pngObj.data, 'image/png').catch(err => { | ||
console.log('Error occured on img png', err) | ||
}) | ||
screenObj.content = pngObj.data | ||
} else { | ||
request.file = {name: sceenshotName} | ||
request.name = sceenshotName | ||
request.message = sceenshotName | ||
reportportal.sendFile([request], sceenshotName, attachment.data, 'image/png').catch(err => { | ||
console.log('Error occured on img screenshot', err) | ||
}) | ||
screenObj.content = attachment.data | ||
} | ||
reportportal.sendLog(context.stepId, request, screenObj) | ||
break | ||
@@ -199,5 +156,3 @@ } | ||
case 'pending': { | ||
reportportal.log({ | ||
item_id: context.stepId, | ||
time: reportportal._now(), | ||
reportportal.sendLog(context.stepId, { | ||
level: 'WARN', | ||
@@ -213,5 +168,3 @@ message: "This step is marked as 'pending'" | ||
case 'undefined': { | ||
reportportal.log({ | ||
item_id: context.stepId, | ||
time: reportportal._now(), | ||
reportportal.sendLog(context.stepId, { | ||
level: 'ERROR', | ||
@@ -227,5 +180,3 @@ message: 'There is no step definition found. Please verify and implement it.' | ||
case 'ambiguous': { | ||
reportportal.log({ | ||
item_id: context.stepId, | ||
time: reportportal._now(), | ||
reportportal.sendLog(context.stepId, { | ||
level: 'ERROR', | ||
@@ -252,32 +203,21 @@ message: 'There are more than one step implementation. Please verify and reimplement it.' | ||
let errorMessage = `${event.stepDefinition.uri}\n ${util.format(event.failureException)}` | ||
reportportal.log({ | ||
item_id: context.stepId, | ||
time: reportportal._now(), | ||
const errorObj = { | ||
level: 'ERROR', | ||
message: errorMessage | ||
}) | ||
.then(result => { | ||
if (browser && config.takeScreenshot && config.takeScreenshot === 'onFailure') { | ||
return browser.takeScreenshot() | ||
.then(png => { | ||
return reportportal.sendFile([ | ||
{ | ||
item_id: context.stepId, | ||
time: reportportal._now(), | ||
level: 'ERROR', | ||
file: {name: sceenshotName}, | ||
message: sceenshotName | ||
}], sceenshotName, png, 'image/png') | ||
} | ||
if (browser && config.takeScreenshot && config.takeScreenshot === 'onFailure') { | ||
browser.takeScreenshot() | ||
.then(png => { | ||
reportportal.sendLog(context.stepId, | ||
errorObj, { | ||
name: sceenshotName, | ||
type: 'image/png', | ||
content: png | ||
}) | ||
.then(result => { | ||
callback() | ||
}) | ||
.catch(error => { | ||
console.log('Failed to send Screenshot, error') | ||
callback(error) | ||
}) | ||
} else { | ||
callback() | ||
} | ||
}) | ||
}) | ||
} else { | ||
reportportal.sendLog(context.stepId, errorObj) | ||
callback() | ||
} | ||
break | ||
@@ -289,4 +229,3 @@ } | ||
let request = { | ||
status: context.stepStatus, | ||
end_time: reportportal._now() | ||
status: context.stepStatus | ||
} | ||
@@ -304,27 +243,12 @@ if (request.status === 'not_found') { | ||
} | ||
reportportal.finishTestItem(context.stepId, request) | ||
.then(result => { | ||
context.stepStatus = 'failed' | ||
context.stepId = null | ||
callback() | ||
}) | ||
.catch(err => { | ||
console.log('Error occured on finishing step', err) | ||
callback() | ||
}) | ||
let launchObj = reportportal.finishTestItem(context.stepId, request) | ||
callback() | ||
}) | ||
this.registerHandler('ScenarioResult', (event, callback) => { | ||
reportportal.finishTestItem(context.scenarioId, { | ||
status: event.status !== 'PASSED' ? 'failed' : 'passed', | ||
end_time: reportportal._now() | ||
let launchObj = reportportal.finishTestItem(context.scenarioId, { | ||
status: event.status !== 'PASSED' ? 'failed' : 'passed' | ||
}) | ||
.then(result => { | ||
context.scenarioStatus = 'failed' | ||
context.scenarioId = null | ||
callback() | ||
}) | ||
.catch(err => { | ||
console.log('Error occured when finishing scenario', err) | ||
callback() | ||
}) | ||
context.scenarioStatus = 'failed' | ||
context.scenarioId = null | ||
callback() | ||
}) | ||
@@ -334,30 +258,17 @@ this.registerHandler('AfterFeature', (event, callback) => { | ||
reportportal.finishTestItem(context.featureId, { | ||
status: featureStatus, | ||
end_time: reportportal._now() | ||
status: featureStatus | ||
}) | ||
.then(result => { | ||
callback() | ||
}) | ||
.catch(err => { | ||
console.log('Error occured when finishing feature', err) | ||
callback() | ||
}) | ||
callback() | ||
}) | ||
this.registerHandler('AfterFeatures', (event, callback) => { | ||
if (!context.launchId) { | ||
console.log('Failed to finish test launch - launchId is not defined') | ||
callback() | ||
} | ||
if (!config.id) { | ||
reportportal.finishLaunch(context.launchId, { | ||
end_time: reportportal._now() | ||
reportportal.finishLaunch(context.launchId, {}).promise.then(() => { | ||
context = cleanReportContext() | ||
callback() | ||
}) | ||
.then(result => callback()) | ||
.catch(err => { | ||
console.log('Error occured dring finishing launch', err) | ||
context = cleanReportContext() | ||
callback() | ||
}) | ||
} else { | ||
callback() | ||
reportportal.getPromiseFinishAllItems(context.launchId).then(() => { | ||
callback() | ||
}) | ||
} | ||
@@ -364,0 +275,0 @@ }) |
@@ -34,3 +34,3 @@ module.exports = () => { | ||
return browser.takeScreenshot() | ||
.then(png => { | ||
.then(png => | ||
_self.attach(JSON.stringify({ | ||
@@ -40,3 +40,3 @@ message: logMessage, | ||
}), 'image/png') | ||
}) | ||
) | ||
} else { | ||
@@ -43,0 +43,0 @@ |
{ | ||
"name": "reportportal-agent-cucumber", | ||
"version": "0.1.1", | ||
"version": "1.0.0", | ||
"description": "Agent that connects cucumber-js with report portal ", | ||
@@ -9,3 +9,3 @@ "main": "./modules/index", | ||
"path": "^0.12.7", | ||
"reportportal-client": "^3.0.0" | ||
"reportportal-client": "^5.0.0" | ||
}, | ||
@@ -12,0 +12,0 @@ "devDependencies": { |
@@ -9,13 +9,4 @@ 'use strict' | ||
*/ | ||
const launchObject = { | ||
name: config.launch, | ||
description: !config.description ? '' : config.description, | ||
tags: config.tags | ||
} | ||
rp.startLaunch( | ||
Object.assign({ | ||
start_time: rp._now() | ||
}, launchObject) | ||
).then(id => { | ||
const launchObj = (rp.startLaunch({})) | ||
launchObj.promise.then(id => { | ||
let cuce = spawn('npm', ['run', 'test', `--id=${id.id}`]) | ||
@@ -27,7 +18,9 @@ | ||
cuce.stderr.on('data', (err) => { | ||
console.log(err.toString()) | ||
}) | ||
cuce.on('close', (code) => { | ||
rp.finishLaunch(id.id, { | ||
end_time: rp._now() | ||
}) | ||
.then(result => console.log('exit with code ' + code)) | ||
rp.finishLaunch(launchObj.tempId, {}).promise | ||
.then(result => console.log('exit with code ' + 'code')) | ||
.catch(err => { | ||
@@ -37,4 +30,2 @@ console.log('Error occured dring finishing launch', err) | ||
}) | ||
}).catch(err => { | ||
console.log('Failed to start launch due to error', config.launch, err) | ||
}) | ||
@@ -45,7 +36,4 @@ | ||
*/ | ||
rp.startLaunch( | ||
Object.assign({ | ||
start_time: rp._now() | ||
}, launchObject) | ||
).then(id => { | ||
const protLaunchObj = rp.startLaunch({}) | ||
protLaunchObj.promise.then(id => { | ||
let protractor = spawn('npm', ['run', 'protractorTest', `--id=${id.id}`]) | ||
@@ -60,5 +48,3 @@ | ||
protractor.on('close', (code) => { | ||
rp.finishLaunch(id.id, { | ||
end_time: rp._now() | ||
}) | ||
rp.finishLaunch(protLaunchObj.tempId).promise | ||
.then(result => console.log('exit with code ' + code)) | ||
@@ -69,4 +55,2 @@ .catch(err => { | ||
}) | ||
}).catch(err => { | ||
console.log('Failed to start launch due to error', config.launch, err) | ||
}) | ||
}) |
@@ -29,3 +29,7 @@ 'use strict' | ||
browser.get('https://github.com/cucumber/cucumber-js/tree/master').then(() => { | ||
callback() | ||
}).then(() => { | ||
this.screenshot('Test screen').then(() => { | ||
callback() | ||
}) | ||
}) | ||
@@ -32,0 +36,0 @@ }) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
29
0
69283
543
+ Added@babel/runtime@7.26.0(transitive)
+ Addedaxios@0.18.1(transitive)
+ Addedaxios-retry@3.9.1(transitive)
+ Addedbalanced-match@1.0.2(transitive)
+ Addedbrace-expansion@1.1.11(transitive)
+ Addedconcat-map@0.0.1(transitive)
+ Addedfollow-redirects@1.5.10(transitive)
+ Addedfs.realpath@1.0.0(transitive)
+ Addedglob@7.2.3(transitive)
+ Addedinflight@1.0.6(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedis-buffer@2.0.5(transitive)
+ Addedis-retry-allowed@2.2.0(transitive)
+ Addedminimatch@3.1.2(transitive)
+ Addedonce@1.4.0(transitive)
+ Addedpath-is-absolute@1.0.1(transitive)
+ Addedregenerator-runtime@0.14.1(transitive)
+ Addedreportportal-client@5.5.0(transitive)
+ Addeduniqid@5.4.0(transitive)
+ Addedwrappy@1.0.2(transitive)
- Removediconv-lite@0.2.11(transitive)
- Removedqs@1.2.0(transitive)
- Removedreportportal-client@3.0.0(transitive)
- Removedrestler@3.4.0(transitive)
- Removedsax@0.5.8(transitive)
- Removedxml2js@0.4.0(transitive)
- Removedxmlbuilder@15.1.1(transitive)
- Removedyaml@0.2.3(transitive)
Updatedreportportal-client@^5.0.0