Skip to content

Storing snapshots inline #116

@adriangb

Description

@adriangb

This looks like a really nice project! I was looking for a snapshot testing library to automate tests that compare some JSON responses. One feature I would really like is to store the snapshots in code. For example, something like this:

def test_foo():
    expected_value = snapshot(
        {...}   # some large dict
    )
    actual_value = foo()
    assert expected_value == actual_value

The reason for this is to keep the expected/snapshotted value close to where it is being used, which makes it a lot easier to inspect the expected value, e.g. in code review.

Although I've never used it, it seems that insta (Rust version) supports this, albeit only for strings. I think native Python objects would be ideal, but storing inline as JSON might be easier.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions