bromide

package module
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 22, 2024 License: MIT Imports: 8 Imported by: 0

README

bromide

A snapshot testing library for go 📸


Introduction

Bromide is a snapshot library for Go, designed to simplify managing snapshot tests.

With Bromide, you can easily capture test output and then review any differences against expected values.

Usage

Write

go get github.com/cobbinma/bromide
import github.com/cobbinma/bromide

func TestSomething(t *testing.T) {
    text := "world"
    something := testStruct{
      example: &text,
      again:   5,
    }
    
    bromide.Snapshot(t, something)
}
--- FAIL: TestSomething (0.00s)
    bromide_test.go:24: snapshot mismatch
    bromide_test.go:24:
        --- current
        +++ incoming
        @@ -1,4 +1,4 @@
         (bromide_test.testStruct) {
        -  example: (*string)((len=5) "hello"),
        +  example: (*string)((len=5) "world"),
           again: (int) 5
         }


    bromide_test.go:24: to update snapshot run `bromide`
FAIL
FAIL    github.com/cobbinma/bromide     0.211s
FAIL

Review

go install github.com/cobbinma/bromide/cmd/bromide@v0.0.2

screenshot

See Also

Thanks

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Snapshot

func Snapshot[K any](t *testing.T, item K, options ...Option)

Types

type Option

type Option func(*config)

func WithPassingNewSnapshots

func WithPassingNewSnapshots(pass bool) Option

WithPassingNewSnapshots configure passing tests if new snapshots are created

func WithSnapshotDirectory

func WithSnapshotDirectory(directory string) Option

WithSnapshotDirectory configure a non default snapshot directory

func WithSnapshotTitle

func WithSnapshotTitle(title string) Option

WithSnapshotTitle add an optional title to a snapshot useful if tests have multiple snapshots

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL