From ba2e81f6047a8fc4404398139e37b32630ee8a7c Mon Sep 17 00:00:00 2001 From: kobenguyent Date: Tue, 30 Apr 2024 16:02:36 +0200 Subject: [PATCH 1/3] fix: screenshots to default output even the custom folder is set --- lib/plugin/stepByStepReport.js | 2 +- lib/utils.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/plugin/stepByStepReport.js b/lib/plugin/stepByStepReport.js index 2f397a06a..854087b87 100644 --- a/lib/plugin/stepByStepReport.js +++ b/lib/plugin/stepByStepReport.js @@ -148,7 +148,7 @@ module.exports = function (config) { stepNum++; slides[fileName] = step; try { - await helper.saveScreenshot(path.relative(reportDir, path.join(dir, fileName)), config.fullPageScreenshots); + await helper.saveScreenshot(path.join(dir, fileName), config.fullPageScreenshots); } catch (err) { output.plugin(`Can't save step screenshot: ${err}`); error = err; diff --git a/lib/utils.js b/lib/utils.js index 4cfaeecb1..fc73a5afb 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -291,7 +291,7 @@ module.exports.screenshotOutputFolder = function (fileName) { const fileSep = path.sep; if (!fileName.includes(fileSep) || fileName.includes('record_')) { - return path.join(global.output_dir, fileName); + return path.resolve(global.output_dir, fileName); } return path.resolve(global.codecept_dir, fileName); }; From cd879af71bfe8b2c42c0b7a4eb2d622fad0048dc Mon Sep 17 00:00:00 2001 From: kobenguyent Date: Tue, 30 Apr 2024 16:17:09 +0200 Subject: [PATCH 2/3] fix: records.html is still created with no screenshots --- lib/plugin/stepByStepReport.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/plugin/stepByStepReport.js b/lib/plugin/stepByStepReport.js index 854087b87..de3498419 100644 --- a/lib/plugin/stepByStepReport.js +++ b/lib/plugin/stepByStepReport.js @@ -116,7 +116,7 @@ module.exports = function (config) { }); event.dispatcher.on(event.all.result, () => { - if (!Object.keys(slides).length) return; + if (Object.keys(recordedTests).length === 0 || !Object.keys(slides).length) return; let links = ''; From 5e560856b8ff9f1b241ce43d251dc09d5485bc1c Mon Sep 17 00:00:00 2001 From: kobenguyent Date: Tue, 30 Apr 2024 23:18:01 +0200 Subject: [PATCH 3/3] fix: error when test failed at beforeSuite --- lib/plugin/stepByStepReport.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/plugin/stepByStepReport.js b/lib/plugin/stepByStepReport.js index de3498419..52fad61e5 100644 --- a/lib/plugin/stepByStepReport.js +++ b/lib/plugin/stepByStepReport.js @@ -112,6 +112,8 @@ module.exports = function (config) { }); event.dispatcher.on(event.test.failed, (test, err) => { + // BeforeSuite/AfterSuite don't have any access to the browser, hence it could not take screenshot. + if (test.ctx._runnable.title.includes('hook: BeforeSuite')) return; persist(test, err); });