Assets
Serve AssetMapper output and public files directly while browser requests remain inside the Symfony test process.
The bundle serves common static assets directly during an in-process browser test. CSS, JavaScript, fonts, and images can reach the real browser without opening a web server or routing every file through HttpKernel.
How an asset request is resolved
For an intercepted host, the asset bridge handles GET and HEAD requests whose path starts with a configured prefix:
AssetMapperProxylooks up the public path in Symfony AssetMapper when it is installed.FilesystemProxysearches the configured public roots.- The asset is returned with its content type, size, cache policy, and last-modified metadata.
- When neither locator resolves the path, the request continues through the Symfony kernel.
AssetMapper is optional. The filesystem path works for applications that publish files directly under public/ or another declared root.
Default configuration
# config/packages/test/playwright.yaml
playwright:
assets:
public_roots:
- '%kernel.project_dir%/public'
prefixes:
- '/assets'
- '/build'
- '/_framework/ux'
disable_cache: true
public_roots are filesystem directories. prefixes are URL path prefixes. A request must match a prefix before the locators try to resolve it.
Add an application asset root
Add roots and prefixes when the test build publishes files outside the default directory:
playwright:
assets:
public_roots:
- '%kernel.project_dir%/public'
- '%kernel.project_dir%/var/test-assets'
prefixes:
- '/assets'
- '/build'
- '/test-assets'
This is useful for generated bundles, fixtures, or a frontend build prepared specifically for the browser suite.
AssetMapper behavior
The AssetMapper locator resolves public paths, including mapped and fingerprinted paths. When an asset carries compiled inline content, that content is served to the browser. Otherwise the locator can use its source file and metadata.
The browser receives the MIME type expected for the file. TypeScript-family assets are served as JavaScript, and common web formats use Symfony Mime when it is available.
Cache policy
The default disable_cache: true response includes a no-store policy. Every test therefore sees the current file generated by the suite.
Set it to false for scenarios that deliberately test browser caching or service-worker behavior:
playwright:
assets:
disable_cache: false
The bridge then sends an immutable cache policy and includes Last-Modified when the locator provides it.
Diagnose asset routing
Enable focused bundle logging to see whether a request was served as an asset or passed to the kernel:
playwright:
debug_logging: true
If a file reaches the kernel, compare its URL with prefixes, then confirm that AssetMapper exposes the public path or that the file exists below a configured root.