mitsuhiko / insta

A snapshot testing library for rust
https://insta.rs
Apache License 2.0
2.07k stars 93 forks source link

Mark `require-full-match` as experimental #497

Open max-sixty opened 1 month ago

max-sixty commented 1 month ago

I did some more testing. There are some corner-cases where it doesn't work; for example if info is used it fails, because our serializer / deserializer doesn't roundtrip.

For example; from the insta tests, One is Map; the other a Struct:

[insta/src/snapshot.rs:440:20] self.metadata.trim_for_persistence() = MetaData {
    source: None,
    assertion_line: None,
    description: Some(
        "The snapshot is four integers",
    ),
    expression: None,
    info: Some(
        Map(
            [
                (
                    String(
                        "env",
                    ),
                    Map(
                        [
                            (
                                String(
                                    "ENVIRONMENT",
                                ),
                                String(
                                    "production",
                                ),
                            ),
                        ],
                    ),
                ),
                (
                    String(
                        "cmdline",
                    ),
                    Seq(
                        [
                            String(
                                "my-tool",
                            ),
                            String(
                                "run",
                            ),
                        ],
                    ),
                ),
            ],
        ),
    ),
    input_file: None,
}
[insta/src/snapshot.rs:441:24] other.metadata.trim_for_persistence() = MetaData {
    source: None,
    assertion_line: None,
    description: Some(
        "The snapshot is four integers",
    ),
    expression: None,
    info: Some(
        Struct(
            "Info",
            [
                (
                    "env",
                    Map(
                        [
                            (
                                String(
                                    "ENVIRONMENT",
                                ),
                                String(
                                    "production",
                                ),
                            ),
                        ],
                    ),
                ),
                (
                    "cmdline",
                    Seq(
                        [
                            String(
                                "my-tool",
                            ),
                            String(
                                "run",
                            ),
                        ],
                    ),
                ),
            ],
        ),
    ),
    input_file: None,
}