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

experimenting with inline snapshot support #70

Open gkampitakis opened 1 year ago

gkampitakis commented 1 year ago

The api right now looks like

Calling the first time

t.Run("my test", func(t *testing.T) {
user := struct{ Name string }{
    Name: "george",
}

snaps.MatchInlineSnapshot(t, user, nil)
})

and then it will populate with the snapshot data

t.Run("my test", func(t *testing.T) {
user := struct{ Name string }{
    Name: "george",
}

snaps.MatchInlineSnapshot(t, user, snaps.Inline("struct { Name string }{Name:\"george\"}"))
})

Still haven't investigated all the edge cases that this can have and I can see being useful but not sure how much is it worth it.

Two issues that are not addressed