jest-snapshot

  • Version 30.4.1
  • Published
  • 94.8 kB
  • 21 dependencies
  • MIT license

Install

npm i jest-snapshot
yarn add jest-snapshot
pnpm add jest-snapshot

Overview

Overview not available.

Index

Variables

variable EXTENSION

const EXTENSION: string;

    variable toMatchInlineSnapshot

    const toMatchInlineSnapshot: MatcherFunctionWithContext<
    Context,
    [propertiesOrSnapshot?: string | object, inlineSnapshot?: string]
    >;

      variable toMatchSnapshot

      const toMatchSnapshot: MatcherFunctionWithContext<
      Context,
      [propertiesOrHint?: string | object, hint?: string]
      >;

        variable toThrowErrorMatchingInlineSnapshot

        const toThrowErrorMatchingInlineSnapshot: MatcherFunctionWithContext<
        Context,
        [inlineSnapshot?: string, fromPromise?: boolean]
        >;

          variable toThrowErrorMatchingSnapshot

          const toThrowErrorMatchingSnapshot: MatcherFunctionWithContext<
          Context,
          [hint?: string, fromPromise?: boolean]
          >;

            Functions

            function addSerializer

            addSerializer: (plugin: Plugin_2) => void;

              function buildSnapshotResolver

              buildSnapshotResolver: (
              config: Config.ProjectConfig,
              localRequire?: Promise<LocalRequire> | LocalRequire
              ) => Promise<SnapshotResolver>;

                function cleanup

                cleanup: (
                fileSystem: FileSystem_2,
                update: Config.SnapshotUpdateState,
                snapshotResolver: SnapshotResolver,
                testPathIgnorePatterns?: Config.ProjectConfig
                ) => { filesRemoved: number; filesRemovedList: Array<string> };

                  function getSerializers

                  getSerializers: () => Plugins;

                    function isSnapshotPath

                    isSnapshotPath: (path: string) => boolean;

                      Classes

                      class SnapshotState

                      class SnapshotState {}

                        constructor

                        constructor(snapshotPath: string, options: SnapshotStateOptions);

                          property added

                          added: number;

                            property expand

                            expand: boolean;

                              property matched

                              matched: number;

                                property snapshotFormat

                                readonly snapshotFormat: SnapshotFormat;

                                  property unmatched

                                  unmatched: number;

                                    property updated

                                    updated: number;

                                      method clear

                                      clear: () => void;

                                        method fail

                                        fail: (testName: string, _received: unknown, key?: string) => string;

                                          method getUncheckedCount

                                          getUncheckedCount: () => number;

                                            method getUncheckedKeys

                                            getUncheckedKeys: () => Array<string>;

                                              method markSnapshotsAsCheckedForTest

                                              markSnapshotsAsCheckedForTest: (testName: string) => void;

                                                method match

                                                match: ({
                                                testName,
                                                received,
                                                key,
                                                inlineSnapshot,
                                                isInline,
                                                error,
                                                testFailing,
                                                }: SnapshotMatchOptions) => SnapshotReturnOptions;

                                                  method removeUncheckedKeys

                                                  removeUncheckedKeys: () => void;

                                                    method save

                                                    save: () => SaveStatus;

                                                      Interfaces

                                                      interface Context

                                                      interface Context extends MatcherContext {}

                                                        property snapshotState

                                                        snapshotState: SnapshotState;

                                                          property testFailing

                                                          testFailing?: boolean;

                                                            interface FileSystem_2

                                                            interface FileSystem_2 {}

                                                              method exists

                                                              exists: (path: string) => boolean;

                                                                method matchFiles

                                                                matchFiles: (pattern: RegExp | string) => Array<string>;

                                                                  interface SnapshotMatchers

                                                                  interface SnapshotMatchers<R extends void | Promise<void>, T> {}

                                                                    method toMatchInlineSnapshot

                                                                    toMatchInlineSnapshot: {
                                                                    (snapshot?: string): R;
                                                                    <U extends Record<keyof T, unknown>>(
                                                                    propertyMatchers: Partial<U>,
                                                                    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.

                                                                    method toMatchSnapshot

                                                                    toMatchSnapshot: {
                                                                    (hint?: string): R;
                                                                    <U extends Record<keyof T, unknown>>(
                                                                    propertyMatchers: Partial<U>,
                                                                    hint?: string
                                                                    ): R;
                                                                    };
                                                                    • 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.

                                                                    • 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.

                                                                    method toThrowErrorMatchingInlineSnapshot

                                                                    toThrowErrorMatchingInlineSnapshot: (snapshot?: 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.

                                                                    method toThrowErrorMatchingSnapshot

                                                                    toThrowErrorMatchingSnapshot: (hint?: string) => R;
                                                                    • Used to test that a function throws a error matching the most recent snapshot when it is called.

                                                                    Type Aliases

                                                                    type LocalRequire

                                                                    type LocalRequire = (module: string) => unknown;

                                                                      type SaveStatus

                                                                      type SaveStatus = {
                                                                      deleted: boolean;
                                                                      saved: boolean;
                                                                      };

                                                                        type SnapshotFormat

                                                                        type SnapshotFormat = Omit<PrettyFormatOptions, 'compareKeys'>;

                                                                          type SnapshotMatchOptions

                                                                          type SnapshotMatchOptions = {
                                                                          readonly testName: string;
                                                                          readonly received: unknown;
                                                                          readonly key?: string;
                                                                          readonly inlineSnapshot?: string;
                                                                          readonly isInline: boolean;
                                                                          readonly error?: Error;
                                                                          readonly testFailing?: boolean;
                                                                          };

                                                                            type SnapshotResolver

                                                                            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;
                                                                            };

                                                                              type SnapshotReturnOptions

                                                                              type SnapshotReturnOptions = {
                                                                              readonly actual: string;
                                                                              readonly count: number;
                                                                              readonly expected?: string;
                                                                              readonly key: string;
                                                                              readonly pass: boolean;
                                                                              };

                                                                                type SnapshotStateOptions

                                                                                type SnapshotStateOptions = {
                                                                                readonly updateSnapshot: Config.SnapshotUpdateState;
                                                                                readonly prettierPath?: string | null;
                                                                                readonly expand?: boolean;
                                                                                readonly snapshotFormat: SnapshotFormat;
                                                                                readonly rootDir: string;
                                                                                };

                                                                                  Package Files (1)

                                                                                  Dependencies (21)

                                                                                  Dev Dependencies (11)

                                                                                  Peer Dependencies (0)

                                                                                  No peer dependencies.

                                                                                  Badge

                                                                                  To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                                                  You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/jest-snapshot.

                                                                                  • Markdown
                                                                                    [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/jest-snapshot)
                                                                                  • HTML
                                                                                    <a href="https://www.jsdocs.io/package/jest-snapshot"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>