Playwright E2E Testing

Run and debug Playwright end-to-end tests for imgcompress. Covers interactive UI mode, step-by-step debug mode, targeted test runs, and validating the full test suite to ensure CI passes before you push.

TestingDevelopment

Playwright E2E Testing

All commands below should be run from the frontend/ directory:

bash
cd frontend

Development and Debugging#

Interactive UI Mode (Recommended)

The best way to work on tests locally. It gives you a visual timeline, time-travel debugging, and DOM snapshots for every test step. I use this on my Mac — it makes debugging Playwright tests much easier.

ImgCompress Playwright E2E interactive UI mode dashboard showing automated browser test execution on macOSImgCompress Playwright E2E interactive UI mode dashboard showing automated browser test execution on macOS

bash
pnpm exec playwright test --ui

Debug Mode

Launches the Playwright Inspector so you can step through tests line by line in a real browser.

bash
pnpm exec playwright test --debug

Targeted Test Execution#

Single test file (fastest feedback)

bash
pnpm exec playwright test --config=playwright.config.ts tests/e2e/avif_SetByFileSize_Download_Test.spec.ts

Feature group (e.g. PDF workflows)

bash
pnpm exec playwright test --config=playwright.config.ts -g "pdf"

Or by filename pattern:

bash
pnpm exec playwright test --config=playwright.config.ts 'tests/e2e/pdf_.*\.spec\.ts'

Full suite (pre-push)

bash
pnpm exec playwright test --config=playwright.config.ts

Key Flags#

FlagDescription
--headedRun in a visible browser window.
--project=<name>Target a specific browser: chromium, firefox, or webkit.
--trace onRecord a trace viewable in the Playwright trace viewer.
--workers=1Force serial execution, helpful for debugging race conditions.

Viewing Reports#

If a test fails in a headless environment (like CI), view the HTML report locally:

bash
pnpm exec playwright show-report