insta-image

This crate provides support for comparing image data in binary insta snapshots. This enables tests of GUI rendering and other image output by comparing an image generated at test time with a snapshot in version control. See https://insta.rs for a detailed introduction to insta.

How to use

Add dev-dependencies to your crate's Cargo.toml. The image formats that you wish to use must be selected by specifying appropriate crate features. At present, only PNG images are supported. If adding by hand:

[dev-dependencies]
insta = "1.47"
insta-image = { version = "1.0", features = ["png"] }

or, with cargo add:

cargo add --dev insta
cargo add --dev insta-image --features png

In your tests, invoke assert_png_snapshot!:

#[test]
fn check_unnamed_snapshot() {
    let image: Vec<u8> = /* get an image from somewhere */
    assert_png_snapshot!(image);
}

#[test]
fn check_named_snapshot() {
    let special_image: Vec<u8> = /* get an image from somewhere */
    // Snapshot name will have "special" in it.
    assert_png_snapshot!("special", special_image);
}

See the insta docs at https://insta.rs for more comprehensive usage and details about the optional cargo insta plugin.

Copyright and license

Copyright (C) 2026, Donald S. Black.

insta-image is distributed under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. See the accompanying LICENSE file.

Description
Compare PNG snapshots with insta (https://insta.rs)
Readme GPL-3.0 406 KiB
Languages
Rust 100%