← Back to library
Playwrightvisualintermediatev1.20+

Screenshot on test failure

Automatically capture a screenshot whenever a test fails.

1// playwright.config.ts
2import { defineConfig } from '@playwright/test';
3
4export default defineConfig({
5  use: {
6    screenshot: 'only-on-failure', // 'on' | 'off' | 'only-on-failure'
7    video: 'retain-on-failure',
8    trace: 'retain-on-failure',
9  },
10});
11
12// Screenshots land in: test-results/<test-name>/screenshot.png
#screenshot#failure#debug