gkampitakis / go-snaps

Jest-like snapshot testing in Go 📸
https://pkg.go.dev/github.com/gkampitakis/go-snaps
MIT License
175 stars 6 forks source link

fix: improve snapshot diff with newlines #71

Closed gkampitakis closed 1 year ago

gkampitakis commented 1 year ago

When creating a snapshot it's saved the format involves adding a newline

[ Test Name ]
\n <- newline
snapshot body
\n  <- newline
---

Until now when creating a diff snashot this new line was added as part of the diff calculation. This did not create false diff reports but when a new a diff report is created those new lines are reported as part of the snapshot body that can create confusion.

Examples before and after:

Screenshot 2023-07-09 at 17 42 02 Screenshot 2023-07-09 at 17 42 05

and also some better improvements on single line diffs

Screenshot 2023-07-09 at 17 45 50 Screenshot 2023-07-09 at 17 45 46