Open scharf opened 2 years ago
I would like to further understand your pain points. The workflow that I like to use is always running tests with --snapshot-update enabled. It seems to me that this avoids all your pain points.
Can you explain why you prefer your workflow?
10
failures10
failuresfix
that fixes 2 of the 10 tests
2
failures (the fixed ones!???!)8
failures: the 8 failing tests0
failures: everything is Ok (but it is not, because to figure out the 8 failing tests, you have to check the modified snapshots)8
failing tests0
failures and 8 modified snapshot files (which on is the one you manually fixed?)7
failures and 1 changed shapshot file (the one I have manually fixed)5
of the files, but breaks on new file
6
failures3
failures ( 2
old ones, and the new one)0
failures3
failures1
failure and 4 modified snapshots4
failures and one modified snapshot...and so on...
To add to this discussion, having a dump file is really useful in situations where an alternate diff tool is needed (think image comparison, large array comparison, etc). If used with the current snapshot.assert_match_dir()
function, dump file cleanup is also quite straightforward using --allow-snapshot-deletion
Just wanted to follow up on this issue, @joseph-roitman is this still open? Adding dump files (or, as the ApprovalTests libraries call them, "received" files) for external diff tools is an essential part of the debugging process toward making judgments about how to move forward with a failed test.
I want to share a little monkey patch I apply to the
Snapshot
class. It fixes three small annoyances:If the current value is different, then create a
"*.dump"
file with the actual result. This can be used to compare the expected result with the actual result. Or you can just copy the actual result to fix the test.If there is no snapshot, it will create the snapshot. This eliminates the need to use the
--snapshot-update
each time you add a new test.If the snapshot is empty, it will re-create it. This is helpful if you want to re-create the snapshot, just empty the file. (Deleting it may cause it to be removed form git in some IDEs, therefore emptying it is a simpler solution.)