webdriverio-community/wdio-html-reporter

Report is not generated when screenshots attached to steps because screenshots are deleted before report generated

AndreyAndreevSkyward opened this issue · 0 comments

Issue: Aggregated Report is not generated and screenshots deleted before report finished generating with wdio-html-nice-reporter.

Switched from older @rpii/wdio-html-reporter to wdio-html-nice-reporter
And the issue with new reporter is when report is aggregated and trying to generate inside onComplete:
and screenshots are attached to the report. With old, @rpii/wdio-html-reporter reporter, report was generated and then screenshots folder was deleted, but with new, wdio-html-nice-reporter, screenshots folder is deleted before report is generated and that breaks flow and final html report is not generated.
I tried multiple thing like removing async/await, adding global.reportAggregator.createReport() into if statement, then() chain functions and all without success
this is onComplete that i use with both reports

onComplete: function (exitCode, config, capabilities, results) { (async () => { await global.reportAggregator.createReport() })(); if (fs.existsSync(downloadDir)) { del([downloadDir]); } if (fs.existsSync(screenshotsDir)) { del([screenshotsDir]); } },
Steps to reproduce:
1 - install and configure @rpii/wdio-html-reporter
2 - run test with screenshots and generate report with provided onComplete:
Result: aggregated html report is generated and screenshots deleted.
3 - uninstall @rpii/wdio-html-reporter and install and configure wdio-html-nice-reporter
4 - run test with screenshots and generate report with provided onComplete:
Result: screenshots are deleted from folder and aggregated report is not generated.
5 - remove del([screenshotsDir]); from onComplete:
6 - run tests
Result: report is generated and screenshots are not deleted

if I do npm install prompt-sync, and add const prompt = require('prompt-sync')(); to wdio.cnfig.js and update onComplete: with command line input we can see at what point report is generated
updated onComplete:
onComplete: function (exitCode, config, capabilities, results) { (async () => { await global.reportAggregator.createReport() })(); if (fs.existsSync(downloadDir)) { del([downloadDir]); } prompt('is report generated?') if (fs.existsSync(screenshotsDir)) { del([screenshotsDir]); } },
steps:
run same tests for both reporters
with new reporter we can see that there is no report at the time scripts at delete screenshots point

image
and we continue we will se that screenshots deleted and report is not generated

image

Where with old reporter we can see report is generated before scripts delete screenshots

image

and if we continue through prompt, screenshots are deleted and report stays with screenshots attached to the steps

image

image