Skip to content

snapshot-diff: a standalone crate for text snapshot diffs (sc-8792) - #20

Merged
ndbroadbent merged 2 commits into
mainfrom
snapshot-diff
Dec 2, 2026
Merged

ndbroadbent merged 2 commits into
mainfrom
snapshot-diff

Conversation

@ndbroadbent

@ndbroadbent ndbroadbent commented Dec 2, 2026 •

Copy link
Copy Markdown
Member

sc-8792 (replanned). Instead of publishing visualci-core, the part another project can genuinely reuse becomes its own crate, snapshot-diff 0.1.0: normalized diffs for text, JSON and HTML snapshots. Laravel Rust's snapshot testing will use it.

Why publish it: no crate on crates.io normalizes text snapshots before diffing them. snapshot-diff does all of this in one crate:

  • JSON with sorted keys, HTML with sorted attributes and collapsed whitespace;
  • ignore rules for volatile values (JSON paths like $.items[*].id, and regular expressions);
  • JSON changes by path (items[3].price: 10 → 12);
  • a unified diff for a failing test's message.

What stays out: the image diff. Talira had nothing listed, so I searched crates.io directly and found blazediff (a pixelmatch-compatible perceptual diff with anti-aliasing detection and an overlay, actively maintained), dify, image-compare and dssim. A standalone image diff is better served by those (Laravel Rust's visual testing chose blazediff), so vci-diff-1 stays inside VisualCI. The README points to blazediff.

The change:

  • crates/visualci-core/src/snapshot_text.rs moves, unchanged, to crates/snapshot-diff/src/lib.rs, with crate docs and a tested example.
  • It depends on regex, serde, serde_json and similar. IgnoreRules derives JsonSchema behind an optional schemars feature.
  • visualci-core depends on it (with schemars) and re-exports it as visualci_core::snapshot_text, so nothing else in the workspace changes. visualci-core drops its own regex dependency.
  • Metadata: Apache-2.0, repository, docs.rs, README, keywords and categories. No VisualCI naming in the API, and the docs only say "Used by VisualCI".
  • release.yml publishes snapshot-diff once per version in its Cargo.toml, after CI passes on main, using the CARGO_REGISTRY_TOKEN secret. A new crates.io token for snapshot-diff is needed (1Password stub crates-io-snapshot-diff-token). Until it's set, the job only warns.
  • CI also lints snapshot-diff without its feature.
  • The workspace goes to 0.2.11, since visualci-core changed (CLI 0.2.10 is the release just merged).

Checked on docspring-dev:

  • snapshot-diff: 12 tests and the doc example pass;
  • visualci-core: 29 tests pass through the re-export;
  • clippy passes across the workspace, and on snapshot-diff without features;
  • cargo publish --dry-run -p snapshot-diff verifies 0.1.0;
  • Cargo.lock changes only by the new package and the version.

Review: no screenshots change.

@visualci-com

visualci-com Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

VisualCI

docspring/visualci · build #115 · 293 unchanged · no changes

This PR vs base: 5 changed since #108, across 2 builds

Updated as builds change. Agents can review with VisualCI's MCP tools.

…tion, ignore rules, JSON changes by path and unified diffs, moved out of visualci-core into a standalone crate (regex, serde, serde_json, similar; schemars optional) that visualci-core re-exports as snapshot_text; release.yml publishes it to crates.io once per version; workspace 0.2.10
@ndbroadbent
ndbroadbent merged commit e2f5d34 into main Dec 2, 2026
10 checks passed
@ndbroadbent
ndbroadbent deleted the snapshot-diff branch December 2, 2026 07:19
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.

1 participant