Freeze#
A birdie and insta inspired snapshot testing library for Go.
Installation#
go get github.com/ptdewey/freeze
Usage#
package package_test
func TestSomething(t *testing.T) {
result := SomeFunction("foo")
freeze.Snap(t, result)
}
To review a set of snapshots, run:
go run github.com/ptdewey/freeze/cmd/freeze review
Freeze can also be used programmatically:
// Example: tools/freeze/main.go
package main
import "github.com/ptdewey/freeze"
func main() {
// This will start the CLI review tool
freeze.Review()
}
Which can then be run with:
go run tools/freeze/main.go
Freeze also includes (in a separate Go module) a Bubbletea TUI in cmd/tui/main.go. (The TUI is shipped in a separate module to make the added dependencies optional)
TUI Usage#
go run github.com/ptdewey/freeze/cmd/tui review
Interactive Controls#
a- Accept current snapshotr- Reject current snapshots- Skip current snapshotA- Accept all remaining snapshotsR- Reject all remaining snapshotsS- Skip all remaining snapshotsq- Quit
Alternative Commands#
# Accept all new snapshots without review
go run github.com/ptdewey/freeze/cmd/tui accept-all
# Reject all new snapshots without review
go run github.com/ptdewey/freeze/cmd/tui reject-all
Disclaimer#
- This package was largely vibe coded, your mileage may vary (but this library provides more of what I want than the ones below).