Skip to content

Commit

Permalink
Add async/await to examples
Browse files Browse the repository at this point in the history
  • Loading branch information
klamping committed Nov 2, 2023
1 parent 50bc918 commit 17b25a7
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,12 @@ const fs = require('fs');

exports.config = {
...
afterTest(test) {
async afterTest(test) {
if (test.passed === false) {
const filename = "screnshot.png";
const outputFile = path.join(__dirname, filename);
browser.saveScreenshot(outputFile);
reportportal.sendFileToTest(test, 'info', filename, fs.readFileSync(outputFile));
await browser.saveScreenshot(outputFile);
await reportportal.sendFileToTest(test, 'info', filename, fs.readFileSync(outputFile));
}
}
...
Expand All @@ -150,14 +150,14 @@ const fs = require('fs');

exports.config = {
...
afterTest(test) {
async afterTest(test) {
if (test.passed === false) {
const filename = "screnshot.png";
const outputFile = path.join(__dirname, filename);
browser.saveScreenshot(outputFile);
await browser.saveScreenshot(outputFile);
//!!
Object.assign(test, {title: test.description}}
reportportal.sendFileToTest(test, 'info', filename, fs.readFileSync(outputFile));
await reportportal.sendFileToTest(test, 'info', filename, fs.readFileSync(outputFile));
}
}
...
Expand All @@ -170,15 +170,15 @@ const reportportal = require('wdio-reportportal-reporter');

exports.config = {
...
afterStep: function (uri, feature, { error, result, duration, passed }, stepData, context) {
afterStep: async function (uri, feature, { error, result, duration, passed }, stepData, context) {
if (!passed) {
let failureObject = {};
failureObject.type = 'afterStep';
failureObject.error = error;
failureObject.title = `${stepData.step.keyword}${stepData.step.text}`;
const screenShot = global.browser.takeScreenshot();
const screenShot = await global.browser.takeScreenshot();
let attachment = Buffer.from(screenShot, 'base64');
reportportal.sendFileToTest(failureObject, 'error', "screnshot.png", attachment);
await reportportal.sendFileToTest(failureObject, 'error', "screnshot.png", attachment);
}
}
...
Expand Down

0 comments on commit 17b25a7

Please sign in to comment.