jest-snapshot

  • Version 29.7.0
  • Published
  • 83.5 kB
  • 20 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,
                                                }: SnapshotMatchOptions) => SnapshotReturnOptions;

                                                  method removeUncheckedKeys

                                                  removeUncheckedKeys: () => void;

                                                    method save

                                                    save: () => SaveStatus;

                                                      Interfaces

                                                      interface Context

                                                      interface Context extends MatcherContext {}

                                                        property snapshotState

                                                        snapshotState: SnapshotState;

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

                                                              Package Files (1)

                                                              Dependencies (20)

                                                              Dev Dependencies (13)

                                                              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>