Bakes Playwright browsers and their system dependencies into the DDEV web image and adds commands to run the tests and view the HTML report.
From the target project's root:
ddev add-on get Metadrop/ddev-playwright
ddev restart # rebuilds the web image so the browsers are baked in.ddev/web-build/Dockerfile.playwright— installs Chromium + Firefox and their OS dependencies into/ms-playwrightat image build time (PLAYWRIGHT_BROWSERS_PATH). No install happens at runtime..ddev/commands/web/playwright— run tests inside the web container..ddev/commands/web/playwright-report— serve the HTML report..ddev/commands/web/playwright-update-snapshots— regenerate visual baselines..ddev/commands/web/playwright-a11y-summary— print a Markdown accessibility summary from the JSON report (via@lullabot/playwright-drupal)..ddev/config.playwright.yaml— exposes the report port (9323) via the router.
# Run the whole suite (passes any Playwright args through)
ddev playwright
ddev playwright --project=chrome-desktop
ddev playwright homepage.spec.js --grep @responsive
# View the HTML report at https://<project>.ddev.site:9323
ddev playwright-report
# Regenerate visual regression baselines (after intentional UI changes)
ddev playwright-update-snapshots
ddev playwright-update-snapshots cisac-visual.spec.js
# Print a Markdown accessibility summary (needs a prior run; reads the JSON report)
ddev playwright --grep @a11y
ddev playwright-a11y-summary
ddev playwright-a11y-summary --mode=annotations # GitHub ::error annotationsThe summary reads
test-results/results.json, so yourplaywright.config.tsmust include the['json', { outputFile: 'test-results/results.json' }]reporter.
The commands default to tests/playwright. To point them elsewhere, set the
variable in .ddev/config.yaml (it overrides the default because the add-on does
not fix it in any config.*.yaml file):
web_environment:
- PLAYWRIGHT_TEST_DIR=path/to/your/playwrightRun ddev restart afterwards.
The browser version is the PLAYWRIGHT_VERSION build ARG, whose default is read
from .ddev/web-build/playwright-version.txt. Keep it in sync with
@playwright/test in your project's package.json. After changing it, run
ddev restart to rebuild the image. (DDEV has no native build-arg field in
config.yaml, so the version lives in this file; you can still override it with
docker build --build-arg PLAYWRIGHT_VERSION=... for manual builds.)
ddev add-on remove playwright
ddev restartTests run automatically on every push via GitHub Actions. See tests/test.bats to run them locally, and README_DEBUG.md for how to debug a failing CI run interactively.
Contributed and maintained by @Metadrop