[−][src]Macro insta::assert_serialized_snapshot_matches
Assets a Serialize
snapshot in YAML format.
The value needs to implement the serde::Serialize
trait and the snapshot
will be serialized in YAML format. This does mean that unlike the debug
snapshot variant the type of the value does not appear in the output.
You can however use the assert_ron_snapshot_matches!
macro to dump out
the value in RON format which retains some
type information for more accurate comparisions.
Example:
assert_serialized_snapshot_matches!("snapshot_name", vec[1, 2, 3]);
Unlike the assert_debug_snapshot_matches
macro, this one has a secondary
mode where redactions can be defined.
The third argument to the macro can be an object expression for redaction.
It's in the form { selector => replacement }
. For more information
about redactions see redactions.
Example:
assert_serialized_snapshot_matches!("name", value, { ".key.to.redact" => "[replacement value]", ".another.key.*.to.redact" => 42 });
The replacement value can be a string, integer or any other primitive value.