Skip to content

fix(playwright): screenshot path resolving to filesystem root#330

Merged
gregberge merged 3 commits into
mainfrom
fix/screenshot-root-path-eacces
Jul 1, 2026
Merged

fix(playwright): screenshot path resolving to filesystem root#330
gregberge merged 3 commits into
mainfrom
fix/screenshot-root-path-eacces

Conversation

@gregberge

Copy link
Copy Markdown
Member

Resolves #329.

Problem

On CI, argosScreenshot() failed with EACCES: permission denied, open '/<name>.png.argos.json' — the metadata/screenshot path resolved to the filesystem root (/).

This required two bugs to line up, both present in the reporter's environment:

  1. Empty project name → absolute name. With no projects array in the Playwright config, the implicit default project has an empty name. getSnapshotNames prefixed the name with ${project.name}/, yielding a leading slash (/hero…). Passed to path.resolve(root, name), the absolute name discards root and resolves to /. This is also why the reporter's documented root override had no effect.

  2. Reporter not detected. Playwright rewrites every non-builtin reporter id to an absolute resolved path (…/node_modules/@argos-ci/playwright/dist/reporter.mjs). checkIsUsingArgosReporter only matched the @argos-ci/playwright/reporter import specifier — which never appears in the resolved path (it ends in /dist/reporter.mjs) — and relied on a fragile exact-path equality fallback. So the reporter went undetected and screenshots fell into the resolve(root, name) write path above.

Fix

Two independent commits, either of which stops the crash; together they also fix the root cause behind it:

  • Avoid absolute screenshot path when project name is empty — only prefix the name when the project name is non-empty.
  • Detect the Argos reporter from its resolved path — match the @argos-ci/playwright package directory (present in both the raw specifier and the resolved path, including pnpm layouts), and guard require.resolve against throwing.

Tests

Added 9 unit tests in util.test.ts covering the empty-project-name case and reporter detection from resolved/pnpm paths (19 passing). check-types is clean.

🤖 Generated with Claude Code

gregberge and others added 2 commits June 30, 2026 22:43
…empty

When no `projects` are configured in the Playwright config, the implicit
default project has an empty name. `getSnapshotNames` prefixed the screenshot
name with `${project.name}/`, producing a leading slash (e.g. `/hero`). Passed
to `path.resolve(root, name)`, the absolute name discards `root` and resolves
to the filesystem root, causing `EACCES: permission denied` when writing the
`.argos.json` metadata on CI.

Only prefix the name when the project name is non-empty.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Playwright rewrites every non-builtin reporter id to an absolute resolved path
(e.g. `…/node_modules/@argos-ci/playwright/dist/reporter.mjs`) when loading the
config. The detection only matched the `@argos-ci/playwright/reporter` import
specifier, which never appears in the resolved path (it ends in
`/dist/reporter.mjs`), and relied on a fragile exact-path equality fallback. As
a result the reporter went undetected and screenshots fell back to the
`resolve(root, name)` write path.

Match the `@argos-ci/playwright` package directory instead, which is present in
both the raw specifier and the resolved path (including pnpm layouts), and guard
`require.resolve` so an unresolvable entry point no longer throws.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@vercel

vercel Bot commented Jun 30, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
argos-js-sdk-reference Ready Ready Preview, Comment Jun 30, 2026 8:48pm

Request Review

@gregberge gregberge merged commit 6734ba0 into main Jul 1, 2026
68 checks passed
@gregberge gregberge deleted the fix/screenshot-root-path-eacces branch July 1, 2026 13:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: argosScreenshot() throws EACCES: permission denied, open '/<name>.png.argos.json' when running with the Argos Playwright reporter on GitHub Actions

2 participants