Open irevoire opened 1 year ago
I would be curious to know if binding redactions manually to the settings would work for you:
fn enable_redactions() -> insta::internals::SettingsBindDropGuard {
let mut settings = insta::Settings::clone_current();
settings.add_redaction("[].enqueuedAt", "date");
settings.bind_to_scope()
}
And then
#[test]
fn my_test() {
let _guard = enable_redactions();
assert_json_snapshot!(task, @"...");
}
Ooooh, I totally missed this one in the doc! Yeah, I think it would work, it's not ideal but it's enough for me, thanks! :grin:
I will keep this open for now. It would definitely be possible to do, but it does come with quite a bit of complexity.
Hey, thanks for this great project; the more I use it, the more I love it.
I just found out about the redaction features, which basically solve all the remaining issues I had with insta :tada: I was wondering, in terms of API, if you ever thought of providing a macro to autogenerate and store the redaction somewhere.
To explain furthermore, here is an example (my current use case); I have this big structure:
As you can see, there are a bunch of dates and a
Duration
that I'm not interested in 99% of the time. And thus most of my tests look like that;Overall I'm super happy with this result. But after copy-pasting this test a bunch of times, I started to think that it should be doable to write an horrendous proc-macro that hardcode my redactions for my structure specifically.
Something like that, I guess;
Do you think this is a direction insta could take in the future?