tapjs/libtap

use v8.serialize(), v8.deserialize() for snapshots?

Closed this issue · 1 comments

This might be a terrible idea, since part of the value in tap's snapshots is that they are mostly human readable (provided you aren't snapshotting objects containing strings with \ in them, since those get quadruple escaped, which is brutal when a string contains \\ and gets snapshotted as {"key": "\\\\\\\\" }).

But maybe we could speed things up a lot by taking advantage of the fact that snapshots usually match.

In --snapshot mode, t.matchSnapshot(obj) would write v8.serialize(obj).

When comparing, we could check that v8.serialize(obj) === snapshot[key], and if they don't, then diff format(obj) vs format(v8.deserialize(snapshot[key])).

That'd be much smaller strings to compare in many cases, and snapshots files that don't grow so massive.

Otoh, it makes diffs useless. So, maybe terrible idea.

Eh, it'd only cut the strings about in half, and we'd lose post hoc analysis. Bad idea.