snapshot

package module
v0.0.0-...-760bb8d Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2022 License: Apache-2.0 Imports: 21 Imported by: 0

README

go-snapshot-testing

Package snapshot provides snapshot testing functionality, similar in concept to Jest for Javascript. to update snapshots, please set the UPDATE_SNAPSHOT environment variable to "1"

UPDATE_SNAPSHOTS=1 go test ./...

Documentation

Index

Constants

View Source
const (
	CI_MODE_ENV_VAR = "CI_MODE"
)
View Source
const UpdateSnapshotEnvVariableName = "UPDATE_SNAPSHOTS"

Variables

This section is empty.

Functions

func AssertMatchesSnapshot

func AssertMatchesSnapshot(t *testing.T, snapshotName string, actualSnapshot *SnapshotType)

Types

type SnapshotDataType

type SnapshotDataType string
const (
	SnapshotDataTypeText  SnapshotDataType = "TEXT"
	SnapshotDataTypeImage SnapshotDataType = "IMAGE"
)

type SnapshotType

type SnapshotType struct {
	DataType   SnapshotDataType
	Value      string
	OnBadMatch func(t *testing.T, expected string) error `json:"-"`
}

func NewImageSnapshot

func NewImageSnapshot(img image.Image) *SnapshotType

func NewTextSnapshot

func NewTextSnapshot(text string) *SnapshotType

Jump to

Keyboard shortcuts

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