Options
All
  • Public
  • Public/Protected
  • All
Menu

jest-screenshot

Index

Type aliases

IdentifierGenerator

IdentifierGenerator: function

Type declaration

    • (testPath: string, currentTestName: string, counter: number): string
    • Parameters

      • testPath: string
      • currentTestName: string
      • counter: number

      Returns string

ReportPathGenerator

ReportPathGenerator: function

Type declaration

    • (testPath: string, currentTestName: string, counter: number): string
    • Parameters

      • testPath: string
      • currentTestName: string
      • counter: number

      Returns string

Variables

Const checksumLength

checksumLength: 5 = 5

Const maxFilenameLength

maxFilenameLength: number = 255 - suffix.length - checksumLength - 3 - maxTestFilenameLength

Const maxTestFilenameLength

maxTestFilenameLength: 75 = 75

Const reportDir

reportDir: string = getReportDir(reportDirName)

reportDirName

reportDirName: string

Const reportsDir

reportsDir: string = path.join(reportDir, "reports")

Const suffix

suffix: ".snap.png" = ".snap.png"

Const toMatchImageSnapshot

  • A matcher for jest with compares a PNG image to a stored snapshot. Behaves similar to .toMatchSnapshot().

    Parameters

    • received: Buffer

      The buffer from the call to expect(...).

    • configuration: JestScreenshotConfiguration

      The configuration object provided when initializing this library with a call to jestScreenshot.

    Returns MatcherResult

    A MatcherResult usable by jest.

Functions

checkImages

  • Performs the actual check for equality of two images.

    Parameters

    • snapshotImage: PngImage

      The image from the snapshot.

    • receivedImage: PngImage

      The image received from the expect(...) call.

    • snapshotNumber: number

      The number of the snapshot in this test.

    • configuration: JestScreenshotConfiguration

      The configuration of the call to toMatchImageSnapshot.

    Returns ImageMatcherResult

    A MatcherResult with pass and a message which can be handed to jest.

config

getFileConfig

  • getFileConfig(): any

getPackageConfig

  • getPackageConfig(): any

getReportDir

  • getReportDir(reportDir: string): string

getReportPath

  • getReportPath(testPath: string, currentTestName: string, snapshotState: SnapshotState, reportDir: string): string
  • Parameters

    • testPath: string
    • currentTestName: string
    • snapshotState: SnapshotState
    • reportDir: string

    Returns string

getSnapshotFileName

  • getSnapshotFileName(testPath: string, currentTestName: string, snapshotState: SnapshotState): string
  • Calculates the filename for an individual image snapshot file. Depending on the configuration the provided identifier generator will be used or a default identifier will be generated.

    Parameters

    • testPath: string

      The testPath from the jest test configuration, leading to the test file.

    • currentTestName: string

      The currentTestName from the jest test configuration, the name of the current it/describe test.

    • snapshotState: SnapshotState

      The snapshotState from the jest test configuration.

    Returns string

    A string used as a filename for the current snapshot.

getSnapshotPath

  • getSnapshotPath(testPath: string, currentTestName: string, snapshotState: SnapshotState, snapshotsDir?: string): string
  • Calculates the absolute path to an individual image snapshot file.

    Parameters

    • testPath: string

      The testPath from the jest test configuration, leading to the test file.

    • currentTestName: string

      The currentTestName from the jest test configuration, the name of the current it/describe test.

    • snapshotState: SnapshotState

      The snapshotState from the jest test configuration.

    • Optional snapshotsDir: string

    Returns string

    A string with the absolute path to the current snapshot.

isJestTestConfiguration

  • isJestTestConfiguration(obj: any): boolean
  • Checks whether the given input is a JestTestConfiguration provided by jest.

    Parameters

    • obj: any

    Returns boolean

isSnapshotState

  • isSnapshotState(obj: any): boolean
  • Checks whether the given input is a SnapshotState provided by jest.

    Parameters

    • obj: any

    Returns boolean

setupJestScreenshot

  • setupJestScreenshot(): void
  • This function is used to setup and initialize jest-screenshot.

    A configuration object can be passed as the first argument.

    Returns void

Const template

Generated using TypeDoc