Skip to content

fix(playwright): no async save video page #4472

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions lib/helper/Playwright.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`,
)
Expand All @@ -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`,
)
Expand Down Expand Up @@ -3917,7 +3917,7 @@ 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
Expand All @@ -3928,11 +3928,10 @@ async function saveVideoForPage(page, name) {
page
.video()
.delete()
.catch((e) => {})
.catch(() => {})
})
return fileName
}

async function saveTraceForContext(context, name) {
if (!context) return
if (!context.tracing) return
Expand Down
Loading