This reporter displays each screenshot attachment next to the test step which can be useful during test results walkthrough in addition to video and trace files.
The html report is written to custom-report/index.html (with assets/), designed to work when tests are started from the VS Code / Cursor Playwright extension as well as from the CLI.
demo.mp4
| Path | Purpose |
|---|---|
src/reporter/custom-report.ts |
Reporter implementation |
src/reporter/custom-report-ui.js |
Client script (copied into report assets/ at run end) |
src/reporter/custom-report-chrome.css |
Status strip / chrome styles for embedded viewers |
playwright-repo-root.cjs |
Stable repo root (__dirname of the shim; not process.cwd()) |
playwright.config.ts |
Registers the reporter with repositoryRoot: PLAYWRIGHT_CONFIG_DIR |
src/config/documentation-mode.ts |
Local documentation toggle; when on, takeScreenshot attaches PNGs (CI always off) |
src/utils/api-util.ts |
attachStepJson(step, name, data) — attach serialized JSON object under the current test.step |
src/utils/screenshot-util.ts |
takeScreenshot(page, label) — attach viewport PNG under the current test.step |
src/utils/step-decorator-util.ts |
@step("Name") — wraps page-object methods in test.step for the same hierarchy |
tests/example.spec.ts |
Examples: inline test.step + screenshots, and @step on a small page class |
Playwright nests attachments under the step that was active when test.info().attach ran. Use test.step (or the @step decorator) around actions, and call takeScreenshot inside that step so PNGs appear inline under it in custom-report/index.html.
Set DOCUMENTATION_MODE in src/config/documentation-mode.ts to "on" locally to record step PNGs; set to "off" for faster local runs. CI always disables documentation attachments regardless of that flag.
- After cloning the repo, open it in your favorite IDE.
npm install(npm dependencies)npx playwright install(plawright browsers)npm test(run playwright test)- After the run finishes, open
custom-report/index.html(absolute path is also printed in Test Output / terminal under[custom-report]).
Optional: npm run report:custom opens Playwright’s viewer for that folder (same as playwright show-report custom-report).
- Copy
src/reporter/(all three reporter files), optionallysrc/utils/screenshot-util.ts,src/utils/step-decorator-util.ts, and a documentation toggle (here:src/config/documentation-mode.ts, or wiretakeScreenshotto your ownbase-config). - Copy
playwright-repo-root.cjsand merge the reporter block fromplaywright.config.tsinto your config. - Add the
verify:custom-report-rootscript frompackage.json(catches missingrepositoryRootwiring, reporter path, andoutputFolder— same checks matter for CLI and VS Code / Cursor Playwright extension runs). - Add
custom-report/to.gitignoreif you do not want generated HTML committed. - Run
npm run verify:custom-report-rootafter editingplaywright.config.ts.
The Playwright extension’s test host can use a different process.cwd() than a terminal run. Passing repositoryRoot from this file keeps output paths and asset resolution consistent.
CLI and extension both load the same playwright.config.ts, so the reporter entry ./src/reporter/custom-report.ts and outputFolder: "custom-report" apply to terminal runs and to runs started from the VS Code / Cursor Testing panel.
- Report looks stale (old CSS/JS) — Embedded viewers cache
report-ui.js/report-chrome.cssaggressively; hard-refresh or reopenindex.html. Each run uses a cache-bust query on those assets. - Wrong folder / empty report — Confirm
repositoryRoot: PLAYWRIGHT_CONFIG_DIRis set andplaywright-repo-root.cjslives next toplaywright.config.ts. - Do not confuse Playwright’s default
playwright-report/(Show HTML Report) withcustom-report/— they are separate outputs.