Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Clean ¶ added in v0.1.3
Clean runs checks for identifying obsolete snapshots and prints a Test Summary.
Must be called in a TestMain
func TestMain(t *testing.M) {
v := t.Run()
// After all tests have run `go-snaps` can check for not used snapshots
snaps.Clean(t)
os.Exit(v)
}
func MatchJSON ¶ added in v0.4.1
func MatchJSON(t testingT, input interface{}, matchers ...interface{})
MatchJSON verifies the input matches the most recent snap file. Input can be a valid json string or []byte or whatever value can be passed successfully on `json.Marshal`.
MatchJSON(t, `{"user":"mock-user","age":10,"email":"mock@email.com"}`)
MatchJSON(t, []byte(`{"user":"mock-user","age":10,"email":"mock@email.com"}`))
MatchJSON(t, User{10, "mock-email"})
matchers is placeholder for now.
func MatchSnapshot ¶
func MatchSnapshot(t testingT, values ...interface{})
MatchSnapshot verifies the values match the most recent snap file
You can pass multiple values
MatchSnapshot(t, 10, "hello world")
or call MatchSnapshot multiples times inside a test
MatchSnapshot(t, 10) MatchSnapshot(t, "hello world")
The difference is the latter will create multiple entries.
func Skip ¶ added in v0.1.3
func Skip(t testingT, args ...interface{})
Wrapper of testing.Skip
Keeps track which snapshots are getting skipped and not marked as obsolete.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.