Playwright Video Recording Not Working Fix
In this tutorial, you'll learn about Playwright Video Recording Not Working Fix. We cover key concepts, practical examples, and best practices.
Your Playwright test videos aren't being recorded — no video files are generated, or the video is empty.
The Problem
// WRONG — video not configured
import { test } from '@playwright/test';
test('login flow', async ({ page }) => {
// Video not recording — no configuration set
});
No video files are created because video recording is off by default.
Step-by-Step Fix
1. Enable video in config
// RIGHT — playwright.config.ts
import { defineConfig } from '@playwright/test';
export default defineConfig({
use: {
video: 'on', // Record for all tests
},
});
2. Choose recording mode
// RIGHT — different video modes
export default defineConfig({
use: {
// 'off' — no recording (default)
// 'on' — record for all tests
// 'retain-on-failure' — record, keep only on failure
// 'on-first-retry' — record on first retry
video: 'retain-on-failure',
},
});
3. Enable video per test
// RIGHT — per-test video override
import { test } from '@playwright/test';
test.use({ video: 'on' });
test('record this test', async ({ page }) => {
await page.goto('https://example.com');
// This test will have a video recording
});
4. Configure video options
// RIGHT — video size and directory
export default defineConfig({
use: {
video: {
mode: 'on',
size: { width: 1280, height: 720 }, // Video resolution
},
},
// Output directory for test artifacts
outputDir: './test-results',
});
Expected output:
✓ login flow (1.5s) [video attached]
Video saved: test-results/login-flow/video.webm
Prevention Tips
- Enable video in
<a href="/testing-qa/playwright/">playwright</a>.config.tswithuse.video - Use
retain-on-failureto save disk space - Set
video: 'on'per-test for specific scenarios - Configure
outputDirfor organized artifact storage - Clean up video files regularly to save disk space
Common Mistakes with video record
- Overlapping type class instances that cause GHC to reject the program with ambiguous dispatch errors
- Non-exhaustive pattern matches that compile with warnings then crash at runtime
- Misunderstanding that
Stringis[Char]with poor performance for large text operations
These mistakes appear frequently in real-world PLAYWRIGHT code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.
Practice Exercise
Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.
This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.
FAQ
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro