You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently the diffing tool used by Cupaloy treats strings as just a sequence of characters. Which is reasonable, but limited.
In particular, it would be fantastic if there were a way to tell it to treat the two strings as JSON. Which would mean:
Whitespace is ignored
Object keys are unordered
That way, any changes to the output that are changes to the raw string but are not meaningful changes to the JSON structure are ignored and will not cause the tests to fail.
In particular, I've had an issue where VSCode auto-formats the JSON within a snapshot file when I'm making changes to it, which then means that everything breaks. Often it actually means it's quicker to delete the file and regenerate it rather than just fixing up one value that's changed because of a code change.
The text was updated successfully, but these errors were encountered:
In reality this would probably just mean changing:
if snapshot == prevSnapshot || takeV1Snapshot(i...) == prevSnapshot {
in cupaloy.go to use a configured diffing function instead of ==. Users can then provide their own means to compare values - e.g. github.com/kinbiko/jsonassert, but maybe even much more complicated things for some cases like image snapshots or whatever.
Currently the diffing tool used by Cupaloy treats strings as just a sequence of characters. Which is reasonable, but limited.
In particular, it would be fantastic if there were a way to tell it to treat the two strings as JSON. Which would mean:
That way, any changes to the output that are changes to the raw string but are not meaningful changes to the JSON structure are ignored and will not cause the tests to fail.
In particular, I've had an issue where VSCode auto-formats the JSON within a snapshot file when I'm making changes to it, which then means that everything breaks. Often it actually means it's quicker to delete the file and regenerate it rather than just fixing up one value that's changed because of a code change.
The text was updated successfully, but these errors were encountered: