Open olsavmic opened 3 months ago
Since Jackson supports ordering of properties and map entries out of the box (ORDER_MAP_ENTRIES_BY_KEYS, SORT_PROPERTIES_ALPHABETICALLY options), allowing to pass an instance of ObjectMapper will make the JsonJacksonApprovals implementation on par with JsonApprovals
in terms of features.
The
org.approvaltests.JsonJacksonApprovals
class should acceptObjectMapper
as an optional parameter, similarly to theorg.approvaltests.JsonApprovals
accepting aFunction1<GsonBuilder, GsonBuilder> gsonBuilder
.The main motivation is to have consistent serialization with the rest of the application, allowing to perform pretty-printing without changing the semantics of the output (typically NULL values present vs missing).
I don't think there is any reason to modify the mapper during verification, therefore I find it safe to pass the actual instance instead of some ObjectMapper factory/builder.
Thank you for the tooling! I really appreciate such a zero-config snapshotting functionality :)