Type Alias SnapshotOptions<T>

SnapshotOptions<T>: {
    dir?: string;
    mode?: SnapshotMode;
    msg?: string;
    name?: string;
    path?: string;
    serializer?: ((actual: T) => string);
}

The options for assertSnapshot.

Type Parameters

  • T = unknown

Type declaration

  • Optionaldir?: string

    Snapshot output directory. Snapshot files will be written to this directory. This can be relative to the test directory or an absolute path.

    If both dir and path are specified, the dir option will be ignored and the path option will be handled as normal.

  • Optionalmode?: SnapshotMode

    Snapshot mode. Defaults to assert, unless the -u or --update flag is passed, in which case this will be set to update. This option takes higher priority than the update flag. If the --update flag is passed, it will be ignored if the mode option is set.

  • Optionalmsg?: string

    Failure message to log when the assertion fails. Specifying this option will cause the diff not to be logged.

  • Optionalname?: string

    Name of the snapshot to use in the snapshot file.

  • Optionalpath?: string

    Snapshot output path. The snapshot will be written to this file. This can be a path relative to the test directory or an absolute path.

    If both dir and path are specified, the dir option will be ignored and the path option will be handled as normal.

  • Optionalserializer?: ((actual: T) => string)

    Function to use when serializing the snapshot. The default is serialize.

      • (actual): string
      • Parameters

        • actual: T

        Returns string