Skip to content

[Feature]: add 'retain-if-last-attempt-fails' to testOptions.video #40936

@victorxavier10

Description

@victorxavier10

🚀 Feature Request

I would like to add a new option for video recording: retain-if-last-attempt-fails. This would record and retain a video only when a test fail on the last attempt.

Example

// playwright.config.ts
import { defineConfig } from '@playwright/test';

export default defineConfig({
  retries: 2,
  use: {
    video: 'retain-if-last-attempt-fails'
  },
});

Motivation

My team uses Playwright E2E testing and we're having difficulties with the video retention options.

Currently, we have several integrated reporters across the company, and video retention retain-on-failure ends up generating a lot of unnecessary videos (I'm dealing with this today after the tests output).

  • 'off' - Do not record video.
  • 'on' - Record video for each test.
  • 'retain-on-failure' - Record video for each test, but remove all videos from successful test runs.
  • 'on-first-retry' - Record video only when retrying a test for the first time (If the test fails on the first run and succeeds on the first retry, the video shown is from the test that passed. To be honest, it doesn't make much sense.)
  • 'retain-if-last-attempt-fails' - Record video only when a test fail on the last attempt.

I'd like to say that it's important to see the system flaw in order to fix it, but we don't need to watch multiple videos of the same flaw. Does that make sense?

Others have already requested similar but more complex implementations.
#30150
#38306
and a few others like them

I would be happy to implement this myself; I'll just wait a few days for feedback or a green light.

Thanks :)

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions