From 60b9ae66ea094434aa2d4d84e46276b5a26fac10 Mon Sep 17 00:00:00 2001 From: Stefan Hildebrandt <695494+hildebrandttk@users.noreply.github.com> Date: Wed, 15 Jul 2026 01:05:07 +0200 Subject: [PATCH] test(integration): add IT_VIDEO option to record test videos MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- integration/README.md | 7 +++++++ integration/run-tests.sh | 6 ++++++ playwright.integration.config.ts | 15 ++++++++++++++- 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/integration/README.md b/integration/README.md index a204e78a..087d269e 100644 --- a/integration/README.md +++ b/integration/README.md @@ -145,6 +145,13 @@ because the UI behaviour is currently incomplete. Worth a look: | `IT_WEBMAIL_URL`| `http://localhost:3000` | Webmail origin | | `IT_JMAP_URL` | `http://localhost:8025` | Stalwart JMAP/admin base URL | | `IT_SMTP_PORT` | `1025` | Stalwart submission port | +| `IT_VIDEO` | `retain-on-failure`| Video capture: `on` records a `.webm` for **every** test; also `off` / `on-first-retry`. Videos land at `integration/test-results//video.webm` | + +Record videos for a whole run (passing tests included): + +```bash +IT_VIDEO=on integration/run-tests.sh # or a single spec: IT_VIDEO=on integration/run-tests.sh 01-login +``` By default the stack is **left running** after the suite so re-runs are fast and you can poke around (webmail on :3000, Stalwart admin on :8025). Tear it down diff --git a/integration/run-tests.sh b/integration/run-tests.sh index 27a7919c..508c32d2 100755 --- a/integration/run-tests.sh +++ b/integration/run-tests.sh @@ -12,6 +12,11 @@ # Usage: # integration/run-tests.sh # whole suite # integration/run-tests.sh 01-login # a single spec (grep on file name) +# +# Env: +# IT_VIDEO=on record a video.webm for every test (not just failures); +# also: off | retain-on-failure (default) | on-first-retry. +# e.g. IT_VIDEO=on integration/run-tests.sh 01-login set -euo pipefail REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)" @@ -32,5 +37,6 @@ docker run --rm --network host \ -v "${REPO_ROOT}":/work -w /work \ -e IT_NO_DOCKER=1 \ -e HOME=/tmp \ + -e IT_VIDEO="${IT_VIDEO:-}" \ "${PW_IMAGE}" \ npx playwright test -c playwright.integration.config.ts ${FILTER:+"$FILTER"} diff --git a/playwright.integration.config.ts b/playwright.integration.config.ts index 4fabdadd..fa296df2 100644 --- a/playwright.integration.config.ts +++ b/playwright.integration.config.ts @@ -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//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' } }], });