snapshottest icon indicating copy to clipboard operation
snapshottest copied to clipboard

Snapshot should take snapshot of data at the moment when snapshot is being taken 😁

Open jentyk opened this issue 3 years ago • 2 comments

I know that title sounds a bit silly, but what I meant is that when the "assert_match" method is run, what should be recorded is a copy of the data, not a reference. It seems that currently what is being recorded is a reference and at the moment of saving the whole snapshot file if the same property is snapshotted twice and it changes in the meantime only the latest value is being saved twice.

jentyk avatar Mar 03 '21 13:03 jentyk

To elaborate on this some more: When a snapshot is stored (or matched, and none exists, and store is called), a reference is stored. This reference is formatted into a representation during tearDownClass. This means that if things are active during the comparison (like context managers), they may not be active when the snapshot is written. (we use a context manager to normalize Django model reprs so we can ignore things like FK columns).

I think the fix may be to format the data when it's stored, rather than on save.

rgalanakis avatar Jul 14 '21 20:07 rgalanakis

this is a duplicate of https://github.com/syrusakbary/snapshottest/issues/99

15r10nk avatar Jul 12 '23 16:07 15r10nk