Macro insta::assert_json_snapshot

source ·
macro_rules! assert_json_snapshot {
    ($($arg:tt)*) => { ... };
Available on crate feature json only.
Expand description

Asserts a Serialize snapshot in JSON format.

Feature: json

This works exactly like assert_yaml_snapshot! but serializes in JSON format. This is normally not recommended because it makes diffs less reliable, but it can be useful for certain specialized situations.


assert_json_snapshot!(vec![1, 2, 3]);

The third argument to the macro can be an object expression for redaction. It’s in the form { selector => replacement } or match .. { selector => replacement }. For more information about redactions refer to the redactions feature in the guide.

The snapshot name is optional but can be provided as first argument.