Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Assert ¶
Assert compares the output in b to the snapshot saved for the current test. If the snapshot file does not yet exist for this test, it will be created and the test will pass. If the snapshot file exists and the test output does not match, the test will fail and a diff will be shown. To update your snapshots, set `UPDATE_SNAPSHOTS=true` when running your test suite. The default config stores snapshots in `__snapshots__` relative to the test directory.
Types ¶
type Config ¶
type Config struct { // Full path to snapshot directory Directory string // Number of lines of context to show with snapshot diffs Context int }
Config holds values for the full path to the snapshot directory and the number of context lines to show with snapshot diffs.
func New ¶
func New(options ...ConfigOption) (*Config, error)
New creates a new config. Options can set the snapshot directory and context. The snapshot directory defaults to __snapshots__ relative to the current working directory. Default 10 context lines. Use `snapshot.Assert` directly if you don't need to change these defaults.
func (*Config) Assert ¶
Assert compares the output in b to the snapshot saved for the current test. If the snapshot file does not yet exist for this test, it will be created and the test will pass. If the snapshot file exists and the test output does not match, the test will fail and a diff will be shown. To update your snapshots, set `UPDATE_SNAPSHOTS=true` when running your test suite.
See `New` for custom configuration options such as where to save testing snapshots.
type ConfigOption ¶
ConfigOption is a functional option that sets config values
func ContextLines ¶
func ContextLines(n int) ConfigOption
ContextLines sets the max number of context lines shown before the diff
func SnapDirectory ¶
func SnapDirectory(dir string) ConfigOption
SnapDirectory sets the snapshot directory to the full path given