Configuration
Configure intercepted hosts, named browsers, tracing, proxies, assets, and runtime overrides for Symfony tests.
Configure the bundle in the Symfony test environment. A small project normally needs only a base URL and the hosts routed into the kernel.
# config/packages/test/playwright.yaml
playwright:
base_url: 'http://localhost'
intercepted_hosts:
- 'localhost'
- '127.0.0.1'
visit('/account') resolves against base_url. Requests whose host appears in intercepted_hosts are handled by the Symfony kernel. Other hosts keep using the browser network.
Top-level options
| Option | Default | Purpose |
|---|---|---|
enabled |
true |
Registers the bundle services and parameters. |
base_url |
PLAYWRIGHT_BASE_URL, then http://localhost |
Resolves relative paths passed to visit(). |
intercepted_hosts |
localhost, 127.0.0.1, testapp.local |
Selects hosts routed into the kernel. |
default_browser |
default |
Selects the named browser exposed through the default service alias. |
node_path |
auto-detected | Sets the Node.js executable globally. |
debug |
%kernel.debug% |
Exposes the bundle debug parameter in the container. |
debug_logging |
false |
Writes routing decisions through the configured logger. |
browsers |
one headless Chromium browser | Defines named browser contexts. |
assets |
public directory and common prefixes | Configures direct asset serving. |
Named browsers
Each entry under browsers becomes a browser context service. The default entry is enough for most suites:
playwright:
default_browser: default
browsers:
default:
type: chromium
headless: true
timeout_ms: 30000
firefox_debug:
type: firefox
headless: false
slowmo_ms: 100
| Browser option | Default | Purpose |
|---|---|---|
type |
chromium |
Chooses chromium, firefox, or webkit. |
headless |
true |
Runs without a visible browser window. |
timeout_ms |
30000 |
Sets the Playwright operation timeout. |
slowmo_ms |
0 |
Delays browser operations for visible debugging. |
args |
[] |
Passes launch arguments to the browser. |
env |
[] |
Passes environment variables to the Node.js server. |
node_path |
global value | Overrides Node.js for this browser. |
min_node_version |
20.0.0 |
Sets the minimum accepted Node.js version. |
channel |
null |
Chooses a browser channel such as chrome-beta. |
screenshot_dir |
null |
Sets the default screenshot directory. |
downloads_dir |
null |
Sets the download directory. |
videos_dir |
null |
Sets the video directory. |
Tracing and proxy
Tracing and proxy settings belong to a named browser:
playwright:
browsers:
default:
type: chromium
tracing:
enabled: true
dir: '%kernel.project_dir%/var/playwright/traces'
screenshots: true
snapshots: true
proxy:
server: 'http://proxy.example:8080'
bypass: 'localhost,127.0.0.1'
The proxy also accepts username and password. Keep credentials in environment variables or the project's secret management instead of committing them to the test configuration.
Runtime overrides
PlaywrightTestCase reads these environment variables for one test run:
PLAYWRIGHT_BROWSER=firefox PLAYWRIGHT_HEADLESS=false vendor/bin/phpunit tests/E2E
PLAYWRIGHT_BROWSERselectschromium,firefox, orwebkit.PLAYWRIGHT_HEADLESScontrols the browser window.PLAYWRIGHT_BASE_URLsupplies the default base URL.PLAYWRIGHT_VERBOSE=1enables routing logs.
Inspect the resolved configuration
Use Symfony's configuration commands to see the available tree and the values resolved for the test environment:
APP_ENV=test bin/console config:dump-reference playwright
APP_ENV=test bin/console debug:config playwright
Asset options have their own Assets page. Browser context services and named autowiring are covered under Services.