In my webdriverio project, the directory structure is as follows: e2e/ utilities/pUtil.js report/screenshot specs wdio.config.js
Within pUtil.js file, I have the following code snippet:
static takeScreenshot(name, failure = false, test) {
const path = './e2e/report/screenshot/';
let fileName = '';
if (!fs.existsSync(path)) {
fs.mkdirSync(path, { recursive: true });
}
if (failure) {
fileName = name + '_fail';
}
fileName = fileName.replace(/ /g, '_') + '.png';
browser.saveScreenshot(path + fileName);
const data = fs.readFileSync(`${path}${fileName}`);
reporter.sendFileToTest(test, 'INFO', fileName, data);
}
My project is set up to generate both allure and report portal reports. However, when a test fails, the screenshot is successfully added to the allure report but not the report portal.
********* FILE NAME IN **********./e2e/report/screenshot/should_allow_us_fail.png
[2021-09-23T01:20:52.483Z] [0-0] ************ outputFile::./e2e/report/screenshot//should_allow_us_fail.png
[2021-09-23T01:20:52.483Z] [0-0] 2021-09-23T01:20:51.026Z ERROR @wdio/sync: Error: ENOENT: no such file or directory, open './e2e/report/screenshot/should_allow_us_fail.png'
[2021-09-23T01:20:52.483Z] [0-0] at Object.openSync (fs.js:457:3)
[2021-09-23T01:20:52.483Z] [0-0] at Object.readFileSync (fs.js:359:35)
I am requesting assistance in identifying what might be missing in this setup.