Skip to content

Commit

Permalink
fix: some logic to add screenshot
Browse files Browse the repository at this point in the history
  • Loading branch information
kobenguyent committed Jan 9, 2024
1 parent b12e640 commit fd7290c
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -359,19 +359,21 @@ module.exports = (config) => {
stepObj.status = step.status || rp_PASSED;
await finishStepItem(stepObj);

let stepMessage;
if (stepObj.status === 'failed' && step.err) {
stepMessage = `[FAILED STEP] - ${(step.err.stack ? step.err.stack : JSON.stringify(step.err))}`;
} else if (stepObj.status === 'failed' && step.helper.currentRunningTest.err) {
stepMessage = `[FAILED STEP] - ${JSON.stringify(step.helper.currentRunningTest.err)}`;
}
await sendLogToRP({ tempId: stepObj.tempId, level: 'ERROR', message: stepMessage });

if (helper && stepObj.status === 'failed') {
const screenshot = await attachScreenshot(`${clearString(test.testTitle)}.failed.png`);
await sendLogToRP({
tempId: stepObj.tempId, level: 'debug', message: 'Last seen screenshot', screenshotData: screenshot,
});
if (stepObj.status === 'failed') {
let stepMessage;
if (step.err) {
stepMessage = `[FAILED STEP] - ${(step.err.stack ? step.err.stack : JSON.stringify(step.err))}`;
} else if (step.helper.currentRunningTest.err) {
stepMessage = `[FAILED STEP] - ${JSON.stringify(step.helper.currentRunningTest.err)}`;
}
await sendLogToRP({ tempId: stepObj.tempId, level: 'ERROR', message: stepMessage });

if (helper) {
const screenshot = await attachScreenshot(`${clearString(test.testTitle)}.failed.png`);
await sendLogToRP({
tempId: stepObj.tempId, level: 'debug', message: 'Last seen screenshot', screenshotData: screenshot,
});
}
}
}
}
Expand Down

0 comments on commit fd7290c

Please sign in to comment.