Repository navigation
feat(vitest): add argosSnapshot for value snapshots anywhere - #339
Merged
Merged
Conversation
Add an `argosSnapshot(name, content, options?)` API that captures a snapshot of any value (not just a screenshot) and uploads it to Argos to diff across builds, mimicking Vitest snapshots (https://vitest.dev/guide/snapshot). Unlike `argosScreenshot`, it does not need a browser and works in both Vitest browser tests and plain Node tests: - Serialization runs on the test side (strings verbatim, everything else via `@vitest/pretty-format`, or a custom `serialize` fn) so browser-only values are serialized before crossing the RPC boundary. - In browser mode it delegates to a new `argosSnapshot` browser command; in Node it writes directly to disk. Browser mode is detected via the `__vitest_browser__` global. - Snapshots are written as `<name>.snapshot.<ext>` (+ `.argos.json` metadata) and support `root`, `extension` and `tag` options. Also: - Update the reporter to upload snapshots (glob `**/*.snapshot.*`, ignoring `**/*.argos.json` sidecars). - Export `getSnapshotMimeType` from `@argos-ci/core`. - Bundle `@vitest/pretty-format` into the dist so its transitive `tinyrainbow` dep resolves when Vitest pre-bundles the package for the browser. - Add unit tests (serialize, snapshot-file, command) and E2E coverage. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds an
argosSnapshot(name, content, options?)API to@argos-ci/vitestthat captures a snapshot of any value (not just a screenshot) and uploads it to Argos to diff across builds — mimicking Vitest snapshots.Unlike
argosScreenshot, it does not need a browser and works in both Vitest browser tests and plain Node tests.How it works
@vitest/pretty-format, or a customserializefn) so browser-only values (DOM nodes, class instances) are serialized before crossing the RPC boundary.argosSnapshotbrowser command; Node writes directly to disk. Browser mode is detected via the__vitest_browser__global.<name>.snapshot.<ext>(+ a.argos.jsonmetadata sidecar attributing them to the@argos-ci/vitestSDK andvitest). Supportsroot,extension, andtag.Reporter
Updated to push snapshots: glob
["**/*.png", "**/*.aria.yml", "**/*.snapshot.*"]withignore: ["**/*.argos.json"]so metadata sidecars aren't uploaded as snapshots.Other changes
getSnapshotMimeTypefrom@argos-ci/core.@vitest/pretty-formatinto the dist — keeping it external made its transitivetinyrainbowdep unresolvable when Vitest pre-bundles the package for the browser.Tests
serialize,snapshot-file(writes real files to a temp dir — effectively a Node integration test),snapshot-command, updatedreporter+index.Build, typecheck, lint, and format all pass. README documents the feature.
🤖 Generated with Claude Code