Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var stepResult = event.getPayloadItem('stepResult');
lastStep = stepResult.getStep();
if (shouldTakeScreenshot(stepResult)) {
log.debug('[chimp][hooks] capturing screenshot');
if (booleanHelper.isTruthy(process.env['chimp.saveScreenshotsToReport'])) {
var screenshotId = lastStep.getUri() + ':' + lastStep.getLine();
// noinspection JSUnresolvedFunction
screenshots[screenshotId] = {
keyword: lastStep.getKeyword(),
name: lastStep.getName(),
uri: lastStep.getUri(),
line: lastStep.getLine(),
png: global.browser.screenshot().value
};
}
if (booleanHelper.isTruthy(process.env['chimp.saveScreenshotsToDisk'])) {
var affix = stepResult.getStatus() !== 'passed' ? ' (failed)' : '';
// noinspection JSUnresolvedFunction
global.browser.captureSync(lastStep.getKeyword() + ' ' + lastStep.getName() + affix);
}
}
});
lastStep = stepResult.getStep();
if (screenshotHelper.shouldTakeScreenshot(stepResult.getStatus())) {
log.debug('[chimp][hooks] capturing screenshot');
if (booleanHelper.isTruthy(process.env['chimp.saveScreenshotsToReport'])) {
const screenshotId = lastStep.getUri() + ':' + lastStep.getLine();
// noinspection JSUnresolvedFunction
screenshots[screenshotId] = {
keyword: lastStep.getKeyword(),
name: lastStep.getName(),
uri: lastStep.getUri(),
line: lastStep.getLine(),
png: global.browser.screenshot().value,
};
}
if (booleanHelper.isTruthy(process.env['chimp.saveScreenshotsToDisk'])) {
const affix = stepResult.getStatus() !== 'passed' ? ' (failed)' : '';
// noinspection JSUnresolvedFunction
const fileName = lastStep.getKeyword() + ' ' + lastStep.getName() + affix;
screenshotHelper.saveScreenshotsToDisk(fileName);
}
}
});
specDone: function(result) {
if (screenshotHelper.shouldTakeScreenshot(result.status)) {
if (booleanHelper.isTruthy(process.env['chimp.saveScreenshotsToDisk'])) {
const affix = result.status !== 'passed' ? ' (failed)' : '';
const fileName = result.fullName + affix;
screenshotHelper.saveScreenshotsToDisk(fileName, projectDir);
}
}
}
});