Approval-based snapshot testing library for Go (mirror)
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Go 99.6%
Just 0.4%
19 1 0

Clone this repository

https://tangled.org/pdewey.com/shutter https://tangled.org/did:plc:hm5f3dnm6jdhrc55qp2npdja/shutter
git@tangled.org:pdewey.com/shutter git@tangled.org:did:plc:hm5f3dnm6jdhrc55qp2npdja/shutter

For self-hosted knots, clone URLs may differ based on your setup.

Download tar.gz
README.md

Freeze#

A birdie and insta inspired snapshot testing library for Go.

New snapshot screen

Snapshot review CLI

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 snapshot
  • r - Reject current snapshot
  • s - Skip current snapshot
  • A - Accept all remaining snapshots
  • R - Reject all remaining snapshots
  • S - Skip all remaining snapshots
  • q - 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).

Other Libraries#