Skip to content

Configuration

Matcher Options

Matcher options can be passed when registering the matchers in the setup file:

ts
registerValidationFileMatchers({
  testDir: "src",
});

Available Options

OptionDefault ValueDescription
testDir.Base directory for tests. The paths of snapshot files will be relative to this directory.
validationDirdata/test/validationDirectory in which golden masters are stored.
outputDirdata/test/outputDirectory in which file snapshots from test runs are stored.
indentSize2Indentation size in spaces used for serializing snapshots.
resolveFileNameresolveNameAsFileCustom resolver for the file path used to store snapshots.

File Snapshot Options

Snapshot options can be passed whenever calling the validation file matcher:

ts
expect(value).toMatchJsonFile({
  name: "snapshot",
});

Common Options

OptionDefault ValueDescription
nameundefinedUnique name of the file snapshot. Used to distinguish multiple file snapshots within the same test.
normalizers[]Custom normalizers to apply before serialization.
resolveFileNameresolveNameAsFileCustom resolver for the file path used to store snapshots.

JSON Snapshot Options

OptionDefault ValueDescription
includeUndefinedObjectPropertiesfalseSerializes undefined properties in objects. By default, they are omitted.

Text Snapshot Options

OptionDefault ValueDescription
fileExtensiontxtFile extension used for storing the text file.