Ava: snapshots are in binary, any way to store in raw text?

Created on 18 May 2018  路  13Comments  路  Source: avajs/ava

is there any way to save snapshots in UTF8 text form rather than like this?

image

Most helpful comment

To fill in for @iamstarkov: Coming from Jest, the feature I miss the most is the interactive mode that Jest has. It really makes updating one snapshot at a time a breeze though that has nothing to do with storing the snapshot as a binary.

Though a problem I found with binary snapshots is when you update a snapshot in two different branches which comes from the same origin branch. Git can diff and merge the markdown files fine but there is always a merge conflict with the binary. What is your thoughts on this?

All 13 comments

The underlying serialization is not meant to be readable, editable or diffable. It has a binary encoding. What you see here is a GZip compression of all serializations.

Why are you concerned about the format?

I suppose we could write Base64 to the file but I don't think that adds any value.

(I'm closing this issue for housekeeping purposes, but let's keep the conversation going.)

I've been using jest and I am used to seeing the snapshots in the git changelog. For our team at @Leaplabs we use those changelogs to showcase data we expect. It's not just an assertion for the test runner-it's for humans as well. Keeping snapshots as binary unfortunately makes snapshots unaproachable for humans.

okay, we'll stick to jest 馃槥

Did you see the Markdown files AVA generates? They鈥檙e the ones meant for us humans :smile:

@novemberborn how hard is it to support non-binary snapshots?

@iamstarkov why are you concerned about the format?

@novemberborn it drives people away from Ava to jest in my company =(

@iamstarkov do you know what in particular they don鈥檛 like?

@novemberborn they are accustomed to jest snapshots and have routines based on text-based snapshots, so they don't understand why Ava needs snapshots to be binary and quite unhappy about it

have routines based on text-based snapshots

@iamstarkov could you elaborate on what those routines are?

To fill in for @iamstarkov: Coming from Jest, the feature I miss the most is the interactive mode that Jest has. It really makes updating one snapshot at a time a breeze though that has nothing to do with storing the snapshot as a binary.

Though a problem I found with binary snapshots is when you update a snapshot in two different branches which comes from the same origin branch. Git can diff and merge the markdown files fine but there is always a merge conflict with the binary. What is your thoughts on this?

Coming from Jest, the feature I miss the most is the interactive mode that Jest has. It really makes updating one snapshot at a time a breeze though that has nothing to do with storing the snapshot as a binary.

That sounds like a nice feature to have!

a problem I found with binary snapshots is when you update a snapshot in two different branches which comes from the same origin branch. Git can diff and merge the markdown files fine but there is always a merge conflict with the binary. What is your thoughts on this?

Interesting. I haven't run into that but that's probably more due to the kind of projects I work on. A custom merge driver which re-runs the appropriate tests may be a solution.

How often do you run into this where the Markdown file also conflicts? Or, if you can recall, where Jest snapshot files had such conflicts?

Since this was closed, I assume there is no way to switch to text based then? I don't see anything in the docs

Here is my reasons for preferring raw output:

  1. Git itself is much better at storing text than binary.
  2. Diffs of outputs are much easier to verify. In a PR I have to basically break the test to see what is different, huge PITA. With raw text, I can just see, in a diff or PR, expected output old has been updated to expected output new
  3. I don't see any benefits to storing in binary besides a very small amount of disk savings?
  4. I can't simply open the snapshots with a standard editor and view them.

@ericwooley AVA outputs both Markdown and binary files. The Markdown files are for us humans, including in PR reviews. The binary files are what enables AVA do to structured and colored diffs when the snapshot differs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nickjanssen picture nickjanssen  路  4Comments

avaly picture avaly  路  4Comments

ehmicky picture ehmicky  路  4Comments

fleg picture fleg  路  3Comments

sindresorhus picture sindresorhus  路  3Comments