Ability to strip prefix from / "comment out" YAML header
I'm using Insta for a programming language project. Some of my test output is pretty-printed source code in Rust (e.g. the expected output after a compiler pass).
It'd be great, for debugging purposes, to have the test output also be valid source code, but the YAML header breaks this. Would it be possible to specify, via a header_prefix setting, a prefix to be stripped from each line of the YAML header? That way, with header_prefix: "// ", one might get
// ---
// source: weird_syntax.rs
// expression: foo
// ---
fn foo(x: ?Foo) { }
one approach some folks are using — use the binary form of snapshots; which then store the header separately — would that work?
It loses the ability to have diffs, as far as I can tell. Since this is source code, diffs are quite valuable to have. I see there is a PR that would allow diffing "binary" text snapshots, but it doesn't seem to have achieved a consensus in its favour.
Additionally, if each test case can be made to be two instead of three files, that's also a small advantage.
Is there a way to disable the header altogether, via e.g. Settings? I feel like at least for my use cases (one snapshot per function) the file name is enough to disambiguate.
Apart from a prefix, simply skipping a line or two would also work for me. That way it would work with C-style multiline comments with no changes to the parsing of the header itself:
/*
---
source: weird_syntax.rs
expression: foo
---
*/
fn foo(x: ?Foo) { }
Is there a way to disable the header altogether, via e.g.
Settings?
at the moment, the only way is with the binary option.
I do think it's worth exploring that at the moment. I'd be keener to add binary diffs / a show_diffs setting; vs a new header_prefix setting...