From 2fcf80b59c96e1fce997be54df81a02c778e87bb Mon Sep 17 00:00:00 2001 From: kobenguyent Date: Fri, 30 Aug 2024 13:21:43 +0200 Subject: [PATCH 1/3] fix: no async saveVideoForPage --- lib/helper/Playwright.js | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/lib/helper/Playwright.js b/lib/helper/Playwright.js index 0921fb1ad..d7f1679bf 100644 --- a/lib/helper/Playwright.js +++ b/lib/helper/Playwright.js @@ -2396,9 +2396,9 @@ class Playwright extends Helper { } if (this.options.recordVideo && this.page && this.page.video()) { - test.artifacts.video = await saveVideoForPage(this.page, `${test.title}.failed`) + test.artifacts.video = saveVideoForPage(this.page, `${test.title}.failed`) for (const sessionName in this.sessionPages) { - test.artifacts[`video_${sessionName}`] = await saveVideoForPage( + test.artifacts[`video_${sessionName}`] = saveVideoForPage( this.sessionPages[sessionName], `${test.title}_${sessionName}.failed`, ) @@ -2424,9 +2424,9 @@ class Playwright extends Helper { async _passed(test) { if (this.options.recordVideo && this.page && this.page.video()) { if (this.options.keepVideoForPassedTests) { - test.artifacts.video = await saveVideoForPage(this.page, `${test.title}.passed`) + test.artifacts.video = saveVideoForPage(this.page, `${test.title}.passed`) for (const sessionName of Object.keys(this.sessionPages)) { - test.artifacts[`video_${sessionName}`] = await saveVideoForPage( + test.artifacts[`video_${sessionName}`] = saveVideoForPage( this.sessionPages[sessionName], `${test.title}_${sessionName}.passed`, ) @@ -3917,19 +3917,12 @@ async function refreshContextSession() { } } -async function saveVideoForPage(page, name) { +function saveVideoForPage(page, name) { if (!page.video()) return null const fileName = `${`${global.output_dir}${pathSeparator}videos${pathSeparator}${uuidv4()}_${clearString(name)}`.slice(0, 245)}.webm` - page - .video() - .saveAs(fileName) - .then(() => { - if (!page) return - page - .video() - .delete() - .catch((e) => {}) - }) + page.video().saveAs(fileName) + if (!page) return + page.video().delete().catch(e => {}) return fileName } From 36ca270963cf8e633d74181f3f8fe937165df98d Mon Sep 17 00:00:00 2001 From: kobenguyent Date: Fri, 30 Aug 2024 13:22:33 +0200 Subject: [PATCH 2/3] fix: no async saveVideoForPage --- lib/helper/Playwright.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/helper/Playwright.js b/lib/helper/Playwright.js index d7f1679bf..b3c08ce90 100644 --- a/lib/helper/Playwright.js +++ b/lib/helper/Playwright.js @@ -3922,7 +3922,10 @@ function saveVideoForPage(page, name) { const fileName = `${`${global.output_dir}${pathSeparator}videos${pathSeparator}${uuidv4()}_${clearString(name)}`.slice(0, 245)}.webm` page.video().saveAs(fileName) if (!page) return - page.video().delete().catch(e => {}) + page + .video() + .delete() + .catch((e) => {}) return fileName } From deed016f20a1104561ed292a84aae33461ae01ee Mon Sep 17 00:00:00 2001 From: kobenguyent Date: Fri, 30 Aug 2024 14:16:01 +0200 Subject: [PATCH 3/3] fix: code --- lib/helper/Playwright.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/helper/Playwright.js b/lib/helper/Playwright.js index b3c08ce90..8e68fc74d 100644 --- a/lib/helper/Playwright.js +++ b/lib/helper/Playwright.js @@ -3920,15 +3920,18 @@ async function refreshContextSession() { function saveVideoForPage(page, name) { if (!page.video()) return null const fileName = `${`${global.output_dir}${pathSeparator}videos${pathSeparator}${uuidv4()}_${clearString(name)}`.slice(0, 245)}.webm` - page.video().saveAs(fileName) - if (!page) return page .video() - .delete() - .catch((e) => {}) + .saveAs(fileName) + .then(() => { + if (!page) return + page + .video() + .delete() + .catch(() => {}) + }) return fileName } - async function saveTraceForContext(context, name) { if (!context) return if (!context.tracing) return