Automated Screenshots and E2E Testing
Framework M includes a built-in screenshot engine based on Playwright. This tool serves two purposes:
- Content Generation: Automatically capturing images for documentation (located in
website/static/img/screenshots). - E2E Verification: Ensuring that the application boots, renders correctly, and authenticates without errors across different domains (Desk and Studio).
The Screenshot Manifest
The engine is driven by a configuration file located at docs/screenshots.yaml. Each entry defines a target to capture:
- id: "desk-dashboard"
url: "/app/dashboard"
base_url: "http://localhost:5173"
selector: "text=Welcome to Framework M" # Job fails if this isn't found
scale: 2 # High-DPI for marketing
theme: "light" # light or dark
Running the Engine
You can run the capture tool locally using the m CLI:
uv run m screenshots \
--target-dir website/static/img/screenshots \
--username admin@example.com \
--password Secret@1234
Options:
--verbose: Shows every step and network request.--trace: Generates a Playwright trace file (trace-2x.zip) for debugging failures.
E2E Verification in CI
In the CI pipeline, the update-screenshots job acts as a full-stack E2E smoke test. It:
- Provisions a fresh database.
- Starts the production API (
m prod) and the Studio service (m studio). - Attempts to log in and capture all pages defined in the manifest.
- Fails the PR if any selector is missing or if any page hits a
429or500error.
Troubleshooting CI Failures
If a screenshot job fails in CI:
- Check the Log: Look for
[Network Error]or[Browser Console]log entries. - Download Artifacts: Download the
trace-2x.zipand open it with Trace Viewer to see exactly what the browser saw at the moment of failure. - Selector Timeouts: If you see a timeout, the page might be loading too slowly for the CI runner. You may need to increase the timeout in
screenshots.pyor use a more robust selector.