Skip to content

feat(vitest): name captures per browser when running several browsers - #425

Merged
gregberge merged 2 commits into
mainfrom
claude/reverent-noyce-20fdc4
Nov 17, 2026
Merged

gregberge merged 2 commits into
mainfrom
claude/reverent-noyce-20fdc4

Conversation

@gregberge

@gregberge gregberge commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

Description

Follow-up to #423 (ARG-517), for @argos-ci/vitest. It fixes the same two problems when Vitest browser mode runs several browser.instances.

Naming

Every instance runs the same tests and writes to the same root, so the last browser overwrote the screenshots and snapshots of the others. Outside Chromium, names now end with browser-[<name>], the same rule as Storybook:

  • button (Chromium, unchanged)

  • button browser-[firefox]

  • resp browser-[webkit] vw-320 (with viewports)

  • Where the browser comes from: ctx.project.config.browser.name on the Node side of both commands. Each instance is a project of its own.

  • Shared rule: it uses getBrowserSuffix from @argos-ci/util, which feat(storybook): name screenshots per browser when running several browsers #423 added, so both SDKs share one definition.

  • Order with the viewport: the browser comes first, the viewport last. vw-<width> is always added last by getScreenshotName, as in the Playwright SDK, so this order holds in every code path. It also groups a browser's viewports together.

  • baseName: suffixed the same way. On Firefox, baseName: "button" points to button browser-[firefox], and to button browser-[firefox] vw-320 for a viewport.

  • argosSnapshot gets the suffix too:

    • Without it, every instance writes the same file in parallel, so the last one to finish wins and the build gets one snapshot.
    • Snapshots can differ between browsers. Anything read from the DOM, user agent or layout does, and in the local run below the snapshot content was different in Firefox.
    • Snapshots written from plain Node tests run once and keep their plain name.
  • Auto-generated names: the browser side reserves room for the suffix when it shortens long names. It reads the browser from server.browser in vitest/browser, which is the same config value. The space is only reserved outside Chromium, so even very long Chromium names don't change.

Single upload with several browsers

Vitest calls the plugin's configureVitest once per instance project, so uploadToArgos added one ArgosReporter per browser, and each one uploaded the whole root. The plugin now creates its reporter once and adds it only if reporters doesn't already include it. This is a separate fix commit.

Type of changes

enhancement, plus a bug fix for the duplicate upload.

Checklist

  • I have read the CONTRIBUTING doc
  • The commits message follows the Conventional Commits' policy
  • Lint and unit tests pass locally
  • I have added tests if needed

Optional checks:

  • My changes requires a change to the documentation
  • I have updated the documentation accordingly

Further comments

Checked locally with a temporary config (not committed): instances: [chromium, firefox, webkit], uploadToArgos: true and no ARGOS_TOKEN. The test took an explicit screenshot, one with viewports and baseName, an auto-named one, and an argosSnapshot:

  • Files: 12, one per capture and browser, e.g. button.png, button browser-[firefox].png, button browser-[webkit].png. The Firefox baseline of resp browser-[firefox] vw-320 is button browser-[firefox] vw-320.png.
  • Upload: one attempt, with a single "Missing Argos repository token" error.

I didn't run the "before" case with this config. The overwrite and the reporter per browser come from reading the code, and match what #423 measured for Storybook.

The existing Chromium e2e tests still pass, and the CI Argos builds keep their names.

Known limits:

  • Two instances of the same browser, such as two Chromium instances with different color schemes, still share names.
  • Setups that ran only Firefox or WebKit get the suffix, so they see their screenshots as new once.
  • The rule only leaves chromium plain. A WebdriverIO chrome instance would get browser-[chrome]. Screenshots need the Playwright provider anyway, but argosSnapshot could run there.

The Vitest docs need a note on per-browser names once this is released.

🤖 Generated with Claude Code

@gregberge gregberge added bug Something isn't working enhancement New feature or request labels Nov 16, 2026
@gregberge
gregberge requested a review from jsfez November 16, 2026 20:47
@gregberge
gregberge force-pushed the claude/reverent-noyce-20fdc4 branch from b5d1b6d to 71f7600 Compare November 17, 2026 14:53
gregberge and others added 2 commits November 17, 2026 16:10
Every browser of `browser.instances` runs the same tests and writes to
the same `root`, so the last browser overwrote the screenshots and
snapshots of the others. Outside Chromium, names and `baseName`s now end
with ` browser-[<name>]`, before the ` vw-<width>` viewport suffix:

- `button` (Chromium, unchanged)
- `button browser-[firefox]`
- `resp browser-[webkit] vw-320`

The browser comes from `ctx.project.config.browser.name`, since each
instance is a project of its own. The rule is `getBrowserSuffix` in
`@argos-ci/util`, shared with `@argos-ci/storybook`. Auto-generated names
reserve room for the suffix, so long Chromium names keep their length.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Vitest runs each browser of `browser.instances` as a project of its own
and calls `configureVitest` for each, so `uploadToArgos` added one
reporter, and uploaded the whole root once, per browser.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@gregberge
gregberge force-pushed the claude/reverent-noyce-20fdc4 branch from 71f7600 to 66c7724 Compare November 17, 2026 15:10
@gregberge
gregberge merged commit 874e055 into main Nov 17, 2026
63 of 65 checks passed
@gregberge
gregberge deleted the claude/reverent-noyce-20fdc4 branch November 17, 2026 15:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant