Skip to content

Configuration

Matcher Options

Matcher options can be passed when defining the matcher:

ts
import { defineValidationFileExpect } from "@cronn/playwright-file-snapshots";

const expect = defineValidationFileExpect({
  validationDir: "custom-validation",
  outputDir: "custom-output",
});
OptionDefault ValueDescription
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.
updateDelay250Delay in ms before repeatable snapshots are created in update mode.

File Snapshot Options

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

ts
await expect(value).toMatchTextFile({
  name: "snapshot",
});
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.
timeoutexpect timeoutRetries the snapshot until it passes or the timeout value is reached.
resolveFileNameresolveNameAsFileCustom resolver for the file path used to store snapshots.
updateDelay250Delay in ms before repeatable snapshots are created in update mode.

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.