Snapshot Comparison
Snapshot testing utility for regression detection with integrated diff output.
Overview
Snapshot Comparison (snapcmp) catches regressions by comparing current output against stored "golden" snapshots. It integrates with output-diffing-utility for rich, semantic diffs of text, JSON, and binary data.
First Tool Using Library Composition
This is the first Tuulbelt tool to use another Tuulbelt tool as a library dependency (not CLI). It imports output-diffing-utility via Cargo path dependency, demonstrating PRINCIPLES.md Exception 2: Tuulbelt tools can compose while maintaining zero external dependencies.
Status: Production Ready (v0.1.0)
Language: Rust
Repository: tuulbelt/snapshot-comparison
Features
Snapshot Testing
Store expected output and automatically detect regressions. Create, check, and update snapshots with simple commands.
Integrated Semantic Diffs
Uses output-diffing-utility for intelligent comparisons:
- Text: Unified diff with context lines
- JSON: Semantic comparison showing field changes
- Binary: Hex dump with byte-level differences
CLI-First Design
Works with any language via stdin/stdout. Pipe output from any program for snapshot testing.
CLI & Library
Use as a command-line tool for shell scripts or integrate as a Rust library.
Zero Runtime Dependencies
Uses only Rust standard library plus output-diffing-utility (another zero-dep Tuulbelt tool).
Quick Start
# Clone the repository
git clone https://github.com/tuulbelt/snapshot-comparison.git
cd snapshot-comparison
# Build
cargo build --release
# Install globally
cargo install --path .
# Create a snapshot
my-program | snapcmp create my-test
# Check against snapshot
my-program | snapcmp check my-testDemo
See the tool in action:

▶ View interactive recording on asciinema.org
Use Cases
API Response Testing
curl -s https://api.example.com/users | snapcmp create users-api
curl -s https://api.example.com/users | snapcmp check users-apiBuild Verification
./build.sh | snapcmp create build-output
./build.sh | snapcmp check build-outputConfiguration Validation
cat config.json | snapcmp create -t json valid-config
cat config.json | snapcmp check valid-configWhy Snapshot Comparison?
Unlike Jest snapshots or insta:
- Zero dependencies - Pure Rust, no runtime dependencies
- Integrated diffs - Rich semantic diffs included
- Format-aware - Understands text, JSON, and binary
- CLI-first - Works with any language
Documentation
- Getting Started - Installation and setup
- CLI Usage - Command-line reference
- Library Usage - Rust API guide
- Examples - Real-world usage patterns
- API Reference - Complete API documentation
Related Tools
- Output Diffing Utility - Semantic diff engine (used internally)
- Test Flakiness Detector - Detect unreliable tests