insta icon indicating copy to clipboard operation
insta copied to clipboard

Trailing whitespace in testcases is ignored for diffs

Open TheNeikos opened this issue 1 year ago • 5 comments

What happened?

I created test snapshots with excessive newlines. This was then corrected later, but there was no error or reported diff due to the now missing newlines at the end.

Reproduction steps

  1. assert a snapshot with a lot of newlines at the end
  2. update the value and remove the newlines
  3. no error/diff is reported

Insta Version

1.29

rustc Version

1.70

What did you expect?

I expected newlines changes to be reported, as this is for a CLI application, the trailing whitespaces are important.

TheNeikos avatar Jun 16 '23 07:06 TheNeikos

That's unfortunately a limitation. I think one way to work with this would be to have users that need whitespace handling to add markers around it that make this more explicit.

mitsuhiko avatar Jun 16 '23 12:06 mitsuhiko

Why is it a Limitation if you don’t mind me asking?

TheNeikos avatar Jun 16 '23 14:06 TheNeikos

@TheNeikos it's a natural effect of how the indentation clean up system functions.

mitsuhiko avatar Jul 13 '23 08:07 mitsuhiko

@TheNeikos it's a natural effect of how the indentation clean up system functions.

Hm, since the newlines in this case are trailing, why would indentation (which usually comes before non-whitespace characters) interact with those?

TheNeikos avatar Jul 13 '23 09:07 TheNeikos

The code that cleans up indentation cannot disambiguate these cases.

mitsuhiko avatar Oct 07 '23 20:10 mitsuhiko