The SDET Playbook

← All questions

How should test artifact collection (tracing, screenshots, video) be configured in CI?

Asked Sep 28, 2026Viewed 0 times

0

How should test artifact collection (tracing, screenshots, video) be configured to capture diagnostic data on failure while maintaining fast CI execution?

1 Answer

Sign in to answer and to vote.

  • 0
    The SDET PlaybookSep 28, 2026

    Record the expensive artifacts only when a test is being retried, and keep cheap ones on failure. Playwright's CI guidance is to record traces on the first retry:

    import { defineConfig } from '@playwright/test';
    
    export default defineConfig({
      retries: process.env.CI ? 2 : 0,
      use: {
        trace: 'on-first-retry',
        video: 'on-first-retry',
        screenshot: 'only-on-failure',
      },
      reporter: [['html', { open: 'never' }]],
    });
    

    The distinction matters. retain-on-failure records a trace or video for every test and deletes it when the test passes, so you pay the recording cost on every run. on-first-retry records only when a test has already failed once, which costs nothing on a green run and still captures the failure you need to debug.

    A trace holds the action timeline, DOM snapshots, console output and network requests. Upload the playwright-report and test-results folders as CI artifacts even when the job fails, then open a trace with npx playwright show-trace path/to/trace.zip or from the HTML report.

    Sources: Playwright trace viewer, Playwright use options, Playwright CI