Replies: 1 comment
-
Yes, see #1861. This would also work for
I use a helper pattern for that, either directly ( |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Would it be possible for Ava to implement some sort of mechanism for us to (globally or per-test) specify how snapshots should be serialized and stored?
Our APIs use Luxon extensively for handling dates/times. Unfortunately, Ava serializes the entire Luxon object when we attempt to snapshot an object that contains a Luxon
DateTime
value.Excerpt from a snapshot:
Ideally, it'd be nice if we could somehow tell Ava that it should serialize
DateTime
objects by calling.toString()
instead of dumping the entire object into the snapshot. That way, the snapshot of this property would look something like:I'd be fine with some sort of "middleware" approach where we could specify a
snapshotSerializer
in Ava's config (or on a per-file basis by calling a hypotheticaltest.snapshotSerializer()
method. This would be a path to a script file that contains a function that Ava calls before it serializes an object. From there, we could implement our own handling for any classes that would benefit from normalization or custom serialization.This could also allow some Ava users to strip/normalize fields/data that are expected to be random or based on a timestamp. (This is especially common in integration tests where it isn't possible to control the timestamps generated by a database or external system)
Beta Was this translation helpful? Give feedback.
All reactions