Skip to content

kodiiing/snapshot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Snapshot

Simple utility to do snapshot testing in Go.

package main_test

import (
    "testing"

    "github.com/kodiiing/snapshot"
)

func TestSnapshot(t *testing.T) {
    var output string = SomeHeavyTask()

    ok, err := snapshot.MatchSnapshot("just-for-fun", output, snapshot.Config{})
    if err != nil {
        var snapshotError snapshot.SnapshotError
        if errors.As(err, &snapshotError) {
            t.Errorf(
                "Mismatched snapshot:\nDifferences: %d\nExpected: %s\nGot: %s",
                snapshotError.Difference,
                snapshotError.Snapshot,
                snapshotError.Received,
            )
        }
    }
}

For further documentation, see pkg.go.dev

License

MIT

About

Simple utility to do snapshot testing in Go

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages