import { Plugin, Plugins, PrettyFormatOptions } from "pretty-format"; import "jest-message-util"; import { Config } from "@jest/types"; import { MatcherContext, MatcherFunctionWithContext } from "expect"; //#region src/SnapshotResolver.d.ts type SnapshotResolver = { /** Resolves from `testPath` to snapshot path. */ resolveSnapshotPath(testPath: string, snapshotExtension?: string): string; /** Resolves from `snapshotPath` to test path. */ resolveTestPath(snapshotPath: string, snapshotExtension?: string): string; /** Example test path, used for preflight consistency check of the implementation above. */ testPathForConsistencyCheck: string; }; declare const EXTENSION = "snap"; declare const isSnapshotPath: (path: string) => boolean; type LocalRequire = (module: string) => unknown; declare const buildSnapshotResolver: (config: Config.ProjectConfig, localRequire?: Promise | LocalRequire) => Promise; //#endregion //#region src/State.d.ts type SnapshotStateOptions = { readonly updateSnapshot: Config.SnapshotUpdateState; readonly prettierPath?: string | null; readonly expand?: boolean; readonly snapshotFormat: SnapshotFormat; readonly rootDir: string; }; type SnapshotMatchOptions = { readonly testName: string; readonly received: unknown; readonly key?: string; readonly inlineSnapshot?: string; readonly isInline: boolean; readonly error?: Error; readonly testFailing?: boolean; }; type SnapshotReturnOptions = { readonly actual: string; readonly count: number; readonly expected?: string; readonly key: string; readonly pass: boolean; }; type SaveStatus = { deleted: boolean; saved: boolean; }; declare class SnapshotState { private _counters; private _dirty; private _index; private readonly _updateSnapshot; private _snapshotData; private readonly _initialData; private readonly _snapshotPath; private _inlineSnapshots; private readonly _uncheckedKeys; private readonly _prettierPath; private readonly _rootDir; readonly snapshotFormat: SnapshotFormat; added: number; expand: boolean; matched: number; unmatched: number; updated: number; constructor(snapshotPath: string, options: SnapshotStateOptions); markSnapshotsAsCheckedForTest(testName: string): void; private _addSnapshot; clear(): void; save(): SaveStatus; getUncheckedCount(): number; getUncheckedKeys(): Array; removeUncheckedKeys(): void; match({ testName, received, key, inlineSnapshot, isInline, error, testFailing }: SnapshotMatchOptions): SnapshotReturnOptions; fail(testName: string, _received: unknown, key?: string): string; } //#endregion //#region src/types.d.ts interface Context extends MatcherContext { snapshotState: SnapshotState; testFailing?: boolean; } interface FileSystem { exists(path: string): boolean; matchFiles(pattern: RegExp | string): Array; } interface SnapshotMatchers, T> { /** * This ensures that a value matches the most recent snapshot with property matchers. * Check out [the Snapshot Testing guide](https://jestjs.io/docs/snapshot-testing) for more information. */ toMatchSnapshot(hint?: string): R; /** * This ensures that a value matches the most recent snapshot. * Check out [the Snapshot Testing guide](https://jestjs.io/docs/snapshot-testing) for more information. */ toMatchSnapshot>(propertyMatchers: Partial, hint?: string): R; /** * This ensures that a value matches the most recent snapshot with property matchers. * Instead of writing the snapshot value to a .snap file, it will be written into the source code automatically. * Check out [the Snapshot Testing guide](https://jestjs.io/docs/snapshot-testing) for more information. */ toMatchInlineSnapshot(snapshot?: string): R; /** * This ensures that a value matches the most recent snapshot with property matchers. * Instead of writing the snapshot value to a .snap file, it will be written into the source code automatically. * Check out [the Snapshot Testing guide](https://jestjs.io/docs/snapshot-testing) for more information. */ toMatchInlineSnapshot>(propertyMatchers: Partial, snapshot?: string): R; /** * Used to test that a function throws a error matching the most recent snapshot when it is called. */ toThrowErrorMatchingSnapshot(hint?: string): R; /** * Used to test that a function throws a error matching the most recent snapshot when it is called. * Instead of writing the snapshot value to a .snap file, it will be written into the source code automatically. */ toThrowErrorMatchingInlineSnapshot(snapshot?: string): R; } type SnapshotFormat = Omit; //#endregion //#region src/plugins.d.ts declare const addSerializer: (plugin: Plugin) => void; declare const getSerializers: () => Plugins; //#endregion //#region src/index.d.ts declare const cleanup: (fileSystem: FileSystem, update: Config.SnapshotUpdateState, snapshotResolver: SnapshotResolver, testPathIgnorePatterns?: Config.ProjectConfig["testPathIgnorePatterns"]) => { filesRemoved: number; filesRemovedList: Array; }; declare const toMatchSnapshot: MatcherFunctionWithContext; declare const toMatchInlineSnapshot: MatcherFunctionWithContext; declare const toThrowErrorMatchingSnapshot: MatcherFunctionWithContext; declare const toThrowErrorMatchingInlineSnapshot: MatcherFunctionWithContext; //#endregion export { Context, EXTENSION, SnapshotMatchers, SnapshotResolver, SnapshotState, addSerializer, buildSnapshotResolver, cleanup, getSerializers, isSnapshotPath, toMatchInlineSnapshot, toMatchSnapshot, toThrowErrorMatchingInlineSnapshot, toThrowErrorMatchingSnapshot };