insta icon indicating copy to clipboard operation
insta copied to clipboard

feat: assert_compact_pretty_json_snapshot

Open nyurik opened this issue 3 months ago • 6 comments

implement #805

nyurik avatar Oct 07 '25 01:10 nyurik

I very much agree with the value of compact snapshots

but I'm a bit worried about macro proliferation; that we have a different macro for each combination of settings. I was already a bit hesitant about assert_compact_json_snapshot, but IIRC @mitsuhiko was keener.

alternatives would include:

  • start with a wrapper in the crate being tested that ran the compact json and then passed to assert_snapshot
  • adding code to insta so we can set settings for how to serialize

@mitsuhiko do you have thoughts?

max-sixty avatar Oct 07 '25 17:10 max-sixty

can we simply re-target assert_compact_json_snapshot to use this new renderer?

P.S. the fewer settings we have in insta, the better - conventions over configuration :)

nyurik avatar Oct 07 '25 17:10 nyurik

can we simply re-target assert_compact_json_snapshot to use this new renderer?

but I think it would be backward incompat because it would require enabling a feature? (and we would want a new feature as it would be adding a dependency...)

max-sixty avatar Oct 07 '25 17:10 max-sixty

unless someone wants to re-implement it in-place... Than again, I have no idea why insta wants to maintain a JSON rendering code rather than just use serde_json? Doesn't seem like a high value thing, esp considering that serde_json is looked at by so many more people...

nyurik avatar Oct 07 '25 17:10 nyurik

P.S. technically adding a small mandatory dependency is not a biggie of course

nyurik avatar Oct 07 '25 18:10 nyurik

Than again, I have no idea why insta wants to maintain a JSON rendering code rather than just use serde_json?

yeah, there's some modest history there; discussions are easy to grab

max-sixty avatar Oct 08 '25 00:10 max-sixty