Skip to content

feat(storybook): name screenshots per browser when running several browsers - #423

Merged
gregberge merged 3 commits into
mainfrom
claude/storybook-screenshots-per-browser-282e1c
Nov 17, 2026
Merged

gregberge merged 3 commits into
mainfrom
claude/storybook-screenshots-per-browser-282e1c

Conversation

@gregberge

Copy link
Copy Markdown
Member

Description

Fixes ARG-517.

When several browsers capture the same stories, every screenshot was named after its story id only and written to the same directory, so the last browser overwrote the others. This applies to Vitest browser instances and to the test-runner's --browsers. Both are confirmed: a three-browser run produced a single set of screenshots.

Naming

Screenshots taken outside Chromium now end with browser-[<name>], after the mode:

  • example-button--primary mode-[dark] (Chromium, unchanged)
  • example-button--primary mode-[dark] browser-[firefox]
  • example-button--primary/in-play mode-[dark] browser-[webkit] (in-play argosScreenshot)

Chromium keeps the plain name, so existing baselines stay valid, even when a browser is added to an existing setup. Names also don't change when a run is filtered with --project or --browser.

Where the browser name comes from:

  • Vitest plugin: ctx.project.config.browser.name. Each instance is a project of its own, and this is set even with persistentContext, where Playwright's context.browser() is null.
  • Test-runner: page.context().browser()?.browserType().name().

The browser was already recorded in the screenshot metadata by @argos-ci/playwright, so that part needed no change.

Single upload with several browsers

Vitest calls the plugin's configureVitest once per instance project, so uploadToArgos added one ArgosReporter per browser and uploaded the screenshots that many times. The plugin now creates its reporter once and adds it only if it isn't there yet. 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 against packages/storybook's stories, with Chromium, Firefox and WebKit. A temporary config was used and isn't committed:

Run Before After
Vitest, instances: [chromium, firefox, webkit] 30 screenshots (overwritten) 90, 30 per browser
Same, uploadToArgos: true, no token 3 reporters 1 upload attempt
test-storybook --browsers chromium firefox webkit overwritten 78, 26 per browser

The e2e config still runs Chromium only, so 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.
  • A test-runner run with a persistent context has no browser to read, so its names stay plain.

@argos-ci/vitest has the same two problems (names without the browser, one reporter per instance). That will come in a separate PR. The docs need a note on per-browser names once this is released.

🤖 Generated with Claude Code

gregberge and others added 2 commits November 16, 2026 21:12
Several browsers (Vitest browser `instances`, the test-runner's
`--browsers`) wrote screenshots under the same story names, so the last
browser overwrote the others. Screenshots taken outside Chromium now end
with ` browser-[<name>]`, after the mode, so each browser gets its own
baselines. Chromium keeps the plain name: existing baselines stay valid,
including when a browser is added to the run.

Fixes ARG-517

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 screenshots once, per browser.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@gregberge gregberge added the enhancement New feature or request label Nov 16, 2026
@linear-code

linear-code Bot commented Nov 16, 2026

Copy link
Copy Markdown

ARG-517

The rule that Chromium keeps the plain name and other browsers get
` browser-[<name>]` moves to `getBrowserSuffix` in `@argos-ci/util`,
next to the viewport suffix, so `@argos-ci/vitest` can use the same
definition. Storybook only puts its mode in front of it.

Also turns the naming tests into tables and builds the plugin tests from
one `configure()` helper.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@gregberge
gregberge requested a review from jsfez November 16, 2026 20:40
@gregberge
gregberge merged commit 0a06dc0 into main Nov 17, 2026
77 checks passed
@gregberge
gregberge deleted the claude/storybook-screenshots-per-browser-282e1c branch November 17, 2026 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant