Replies: 3 comments 14 replies
-
Yea! And as long as it's backwards compatible with the v2 format, it wouldn't even need a major release.
I think it is, but it's been a few years since I've looked at that code.
This might not be worthwhile… I have not looked at bson much, but working with Protobufs in the day job I wouldn't want to load all that complexity into AVA. |
Beta Was this translation helpful? Give feedback.
-
Doing this backwards-compatibly is probably possible, but seems somewhat impractical and maybe not beneficial. The main issues I'm seeing are declaration-ordering and release timing. Currently, when snapshots are added or changed, AVA appends them to the report and rewrites the Putting the
The second issue is release timing. If new features are added that rely on being able to regenerate the snapshot report, then they would need to either:
|
Beta Was this translation helpful? Give feedback.
-
@novemberborn I propose to use either
An
Found one issue with this: if the old snapshots exist but are unreadable (most likely because the snapshot format version was just incremented) then copying forward snapshot data naturally doesn't work. Options:
What do you think? |
Beta Was this translation helpful? Give feedback.
-
It seems like several issues (#2635, #2634, #1768; #2099 is tangentially related) might be easier to address if the
.snap
files contained enough information fo the snapshot report to be generated solely from the snapshot file.There are three pieces of information I can think of that are missing from the v2
.snap
file:I think that, if all of this information were present in the
.snap
file, then it would be possible to allow usingtest.skip()
,test.only()
,t.snapshot.skip()
,--match
et al when running--update-snapshots
. The snapshot manager would load existing snapshots from disk at the start of the run, and when a skipped test or snapshot was declared, it would record a "blank space" (or to put it another way, copy over the old snapshot(s)). This would address #2635, by allowing AVA's existing tools to be used to "partially" update a file's snapshots, and #2634, by removing the need for the "Could not update snapshots" message entirely.One caveat with the above: snapshot blocks which actually go entirely untouched (for instance because a test or
id
'd snapshot assertion was removed entirely, not justskip()
ed) can't be ordered relative to new snapshot blocks. This has two effects:id
s could no longer be sorted in declaration order, because they might only be touched inskip()
ed tests. Probably they would have to be sorted to the end of the report file in alphabetical order. Maybe there's a magic solution involving associating them with the test titles that use them.--update-snapshots
, or refrain from recording new snapshots until run with--update-snapshots
. Either of these would be a substantial change to the workflow.--commit-snapshots
behavior described in Consider not updating snapshots automatically #2099.#1768 suggested that this added information would be useful or necessary for writing tools that operate on AVA's snapshot files, because otherwise consumers would need to additionally parse the report file, which isn't designed to be machine-readable (and isn't necessarily governed by the same versioning scheme as
.snap
files).This could also be an opportunity to add additional functionality to the
.snap
file format, such as:List of long-shot suggestions
attaching arbitrary annotations to snapshots, as envisioned in Exposing snapshot manager logic as a library #1768
recording any concordance plugins used
I'm not sure if this is practical or useful. I'm imagining recording the npm package name and version of the plugin, so that consumers (incl. AVA itself, if it ever comes to support customization of
concordance
plugins) can at least know if that plugin is available to them and not accidentally deserialize with an incompatible concordance configuration. Potentially this would be better handled inconcordance
, by encoding the plugins used in the descriptor serialization itself (for all I know, this is already done).adopting a more general binary format, e.g. bson, to make future changes to the snapshot format somewhat easier and potentially not require a major version bump
Using a tagged-type, named-field format like bson would allow adding fields to the snapshot data structures while retaining the ability to parse old snapshot files (without duplicating the entire serialize/deserialize code). New features could then be opted-into on a per-file or per-snapshot basis, though there would be some code duplication involved there, as the codepath for handling snapshots without the new feature would have to be retained. (This is probably wishful thinking, it might turn out to be impossible to ship such features in a user-intelligible way, and there might never be any such features in any case.)
@novemberborn is this worth exploring? I'd be happy to implement this, especially if there's any chance it's in-scope for [email protected]
Beta Was this translation helpful? Give feedback.
All reactions