There's been some recent changes on how insta handles newlines. IIUC, we now just trim them from the start and end of every snapshot; this avoids showing incorrect diffs and inline snapshots failing to discriminate between newlines in the code and newlines in the snapshot.
I think there's an approach that would handle this well, but not confident and wanted to socialize it in case I'm missing something:
- If an inline snapshot is sufficiently short1, it can go on one line; i.e.
assert_snapshot!("foo", @"foo");
- If an inline snapshot isn't sufficiently short, a newline gets added at the start and end which aren't part of the snapshot value; i.e.:
assert_snapshot!(foo, @r#"
multiple
lines
#");
...has a snapshot value of two lines; excluding the first and last newlines within the string
- Then, if there are newlines in the snapshot value, these can then be recognized because we know we've added exactly one newline at the start and at the end. Here's an example if the snapshot value had a leading newline:
assert_snapshot!(foo, @r#"
multiple
lines
#");
This way, I don't think there can be any ambiguity.
There's been some recent changes on how insta handles newlines. IIUC, we now just trim them from the start and end of every snapshot; this avoids showing incorrect diffs and inline snapshots failing to discriminate between newlines in the code and newlines in the snapshot.
I think there's an approach that would handle this well, but not confident and wanted to socialize it in case I'm missing something:
This way, I don't think there can be any ambiguity.
Footnotes
this generally means "is only one line", though very long single lines could start on the next line and become multiline ↩