gkampitakis / go-snaps

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

fix: skip creating multiple same snaspshots #67

Closed gkampitakis closed 1 year ago

gkampitakis commented 1 year ago

When running tests with count >= 2 multiple snapshots ( >=2 ) are created from the same call. This is a design flag IMO.

My expectation is when someone runs golang tests with count > -2 wants to run the tests repeatedly and assert the data with the same snasphots and not create new ones.

This is a BREAKING CHANGE from the point of view that the library will stop having the same behaviour. Old tests should still keep passing but if people run their tests with count >= 2 then some of the snapshots will no longer be used for assertions and will be useless.

gkampitakis commented 1 year ago

After testing this doesn't look really feasible as it breaks one of the ( IMO ) useful features of go-snaps calling matchSnapshot multiple times inside a single test. I can't figure a way of identifying if a call to snaps.Match* is on purpose or due the --count flag.