gkampitakis / go-snaps

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

[Feature Request]: Ability to update snapshots and clean obsolete in one go #106

Closed satazor closed 4 months ago

satazor commented 4 months ago

🚀 Feature Proposal

Ability to update snapshots and clean obsolete in one go. Just like jest and vitest, when -u is used it not only update snapshots but also remove obsolete ones.

Motivation

So that we don't have to run tests twice to do update an clean obsolete snapshots.

Example

One possibile solution is to deprecated UPDATE_SNAPS and allow GO_SNAPS value to be a comma separated set of actions.

This is just one of the many solutions. Another one would be to keep UPDATE_SNAPS env var but we would need to find an alternative name to update action since it's already in the env var name itself, maybe refresh.

gkampitakis commented 4 months ago

Hey :wave: UPDATE_SNAPS=true should be the way.

UPDATE_SNAPS=clean just removes obsolete snapshots. UPDATE_SNAPS=true does both in one go. Are you noticing any issues with it? or haven't tried it?

satazor commented 4 months ago

Nevermind, you are right. It's already like you said, I had a mistake in my makefile. Thanks for the quick response.