test(integration): add IT_VIDEO option to record test videos

Make Playwright's video capture configurable via IT_VIDEO (on | off |
retain-on-failure [default] | on-first-retry) so a whole run — passing tests
included — can be recorded, e.g. for a demo or to inspect a flow. Forward the
env through the Playwright container in run-tests.sh and document it in the
README's environment-knobs table.
This commit is contained in:
Stefan Hildebrandt
2026-07-21 20:56:27 +02:00
committed by Linus Rath
parent abd493fb4c
commit 60b9ae66ea
3 changed files with 27 additions and 1 deletions
+14 -1
View File
@@ -9,6 +9,19 @@ import { defineConfig } from '@playwright/test';
*/
const WEBMAIL_URL = process.env.IT_WEBMAIL_URL ?? 'http://localhost:3000';
/**
* Video capture mode, overridable via IT_VIDEO. Default `retain-on-failure`
* keeps a .webm only for tests that fail. Set `IT_VIDEO=on` to record every
* test (e.g. for a demo or to inspect a passing flow), `off` to disable, or
* `on-first-retry` to record only when a test is retried. Videos land next to
* the other artefacts under `integration/test-results/<test>/video.webm`.
*/
type VideoMode = 'off' | 'on' | 'retain-on-failure' | 'on-first-retry';
const VIDEO_MODES: VideoMode[] = ['off', 'on', 'retain-on-failure', 'on-first-retry'];
const VIDEO: VideoMode = VIDEO_MODES.includes(process.env.IT_VIDEO as VideoMode)
? (process.env.IT_VIDEO as VideoMode)
: 'retain-on-failure';
export default defineConfig({
testDir: './integration/tests',
// next dev compiles routes lazily and each test logs in fresh, so give
@@ -26,7 +39,7 @@ export default defineConfig({
baseURL: WEBMAIL_URL,
screenshot: 'only-on-failure',
trace: 'retain-on-failure',
video: 'retain-on-failure',
video: VIDEO,
},
projects: [{ name: 'chromium', use: { browserName: 'chromium' } }],
});