jest-resolve

  • Version 30.4.1
  • Published
  • 61.9 kB
  • 8 dependencies
  • MIT license

Install

npm i jest-resolve
yarn add jest-resolve
pnpm add jest-resolve

Overview

Overview not available.

Index

Functions

function cachedShouldLoadAsEsm

cachedShouldLoadAsEsm: (
path: string,
extensionsToTreatAsEsm: Array<string>
) => boolean;

    function resolveRunner

    resolveRunner: (
    resolver: string | undefined | null,
    {
    filePath,
    rootDir,
    requireResolveFunction,
    }: {
    filePath: string;
    rootDir: string;
    requireResolveFunction: (moduleName: string) => string;
    }
    ) => string;
    • Finds the runner to use:

      1. looks for jest-runner- relative to project. 1. looks for jest-runner- relative to Jest. 1. looks for relative to project. 1. looks for relative to Jest.

    function resolveSequencer

    resolveSequencer: (
    resolver: string | undefined | null,
    {
    filePath,
    rootDir,
    requireResolveFunction,
    }: {
    filePath: string;
    rootDir: string;
    requireResolveFunction: (moduleName: string) => string;
    }
    ) => string;

      function resolveTestEnvironment

      resolveTestEnvironment: ({
      rootDir,
      testEnvironment: filePath,
      requireResolveFunction,
      }: {
      rootDir: string;
      testEnvironment: string;
      requireResolveFunction: (moduleName: string) => string;
      }) => string;
      • Finds the test environment to use:

        1. looks for jest-environment- relative to project. 1. looks for jest-environment- relative to Jest. 1. looks for relative to project. 1. looks for relative to Jest.

      function resolveWatchPlugin

      resolveWatchPlugin: (
      resolver: string | undefined | null,
      {
      filePath,
      rootDir,
      requireResolveFunction,
      }: {
      filePath: string;
      rootDir: string;
      requireResolveFunction: (moduleName: string) => string;
      }
      ) => string;
      • Finds the watch plugins to use:

        1. looks for jest-watch- relative to project. 1. looks for jest-watch- relative to Jest. 1. looks for relative to project. 1. looks for relative to Jest.

      Classes

      class Resolver

      class Resolver {}

        constructor

        constructor(moduleMap: IModuleMap, options: ResolverConfig);

          property ModuleNotFoundError

          static ModuleNotFoundError: typeof ModuleNotFoundError;

            property unstable_shouldLoadAsEsm

            static unstable_shouldLoadAsEsm: (
            path: string,
            extensionsToTreatAsEsm: string[]
            ) => boolean;

              method canResolveSync

              canResolveSync: () => boolean;

                method clearDefaultResolverCache

                static clearDefaultResolverCache: () => void;

                  method findNodeModule

                  static findNodeModule: (
                  path: string,
                  options: FindNodeModuleConfig
                  ) => string | null;

                    method findNodeModuleAsync

                    static findNodeModuleAsync: (
                    path: string,
                    options: FindNodeModuleConfig
                    ) => Promise<string | null>;

                      method getGlobalPaths

                      getGlobalPaths: (moduleName?: string) => Array<string>;

                        method getMockModule

                        getMockModule: (
                        from: string,
                        name: string,
                        options?: Pick<ResolveModuleConfig, 'conditions'>
                        ) => string | null;

                          method getMockModuleAsync

                          getMockModuleAsync: (
                          from: string,
                          name: string,
                          options: Pick<ResolveModuleConfig, 'conditions'>
                          ) => Promise<string | null>;

                            method getModule

                            getModule: (name: string) => string | null;

                              method getModuleID

                              getModuleID: (
                              virtualMocks: Map<string, boolean>,
                              from: string,
                              moduleName: string | undefined,
                              options: ResolveModuleConfig
                              ) => string;

                                method getModuleIDAsync

                                getModuleIDAsync: (
                                virtualMocks: Map<string, boolean>,
                                from: string,
                                moduleName: string | undefined,
                                options: ResolveModuleConfig
                                ) => Promise<string>;

                                  method getModulePath

                                  getModulePath: (from: string, moduleName: string) => string;

                                    method getModulePaths

                                    getModulePaths: (from: string) => Array<string>;

                                      method getPackage

                                      getPackage: (name: string) => string | null;

                                        method isCoreModule

                                        isCoreModule: (moduleName: string) => boolean;

                                          method normalizeCoreModuleSpecifier

                                          normalizeCoreModuleSpecifier: (specifier: string) => string;

                                            method resolveModule

                                            resolveModule: (
                                            from: string,
                                            moduleName: string,
                                            options?: ResolveModuleConfig
                                            ) => string;

                                              method resolveModuleAsync

                                              resolveModuleAsync: (
                                              from: string,
                                              moduleName: string,
                                              options?: ResolveModuleConfig
                                              ) => Promise<string>;

                                                method resolveModuleFromDirIfExists

                                                resolveModuleFromDirIfExists: (
                                                dirname: string,
                                                moduleName: string,
                                                options?: ResolveModuleConfig
                                                ) => string | null;

                                                  method resolveModuleFromDirIfExistsAsync

                                                  resolveModuleFromDirIfExistsAsync: (
                                                  dirname: string,
                                                  moduleName: string,
                                                  options?: ResolveModuleConfig
                                                  ) => Promise<string | null>;

                                                    method resolveStubModuleName

                                                    resolveStubModuleName: (
                                                    from: string,
                                                    moduleName: string,
                                                    options?: Pick<ResolveModuleConfig, 'conditions'>
                                                    ) => string | null;

                                                      method resolveStubModuleNameAsync

                                                      resolveStubModuleNameAsync: (
                                                      from: string,
                                                      moduleName: string,
                                                      options?: Pick<ResolveModuleConfig, 'conditions'>
                                                      ) => Promise<string | null>;

                                                        method tryCastModuleNotFoundError

                                                        static tryCastModuleNotFoundError: (
                                                        error: unknown
                                                        ) => ModuleNotFoundError | null;

                                                          Interfaces

                                                          interface ResolverOptions

                                                          interface ResolverOptions extends Omit<NapiResolveOptions, 'extensions'> {}

                                                            property basedir

                                                            basedir: string;
                                                            • Directory to begin resolving from.

                                                            property conditions

                                                            conditions?: ReadonlyArray<string>;
                                                            • List of export conditions.

                                                            property defaultAsyncResolver

                                                            defaultAsyncResolver: AsyncResolver;
                                                            • Instance of default async resolver.

                                                            property defaultResolver

                                                            defaultResolver: SyncResolver;
                                                            • Instance of default resolver.

                                                            property extensions

                                                            extensions?: ReadonlyArray<string>;
                                                            • List of file extensions to be considered when resolving.

                                                            property moduleDirectory

                                                            moduleDirectory?: ReadonlyArray<string>;
                                                            • List of directory names to be looked up for modules recursively.

                                                            property paths

                                                            paths?: ReadonlyArray<string>;
                                                            • List of require.paths to use if nothing is found in node_modules.

                                                            property rootDir

                                                            rootDir?: string;
                                                            • Current root directory.

                                                            Type Aliases

                                                            type AsyncResolver

                                                            type AsyncResolver = (path: string, options: ResolverOptions) => Promise<string>;

                                                              type FindNodeModuleConfig

                                                              type FindNodeModuleConfig = {
                                                              basedir: string;
                                                              conditions?: ReadonlyArray<string>;
                                                              extensions?: ReadonlyArray<string>;
                                                              moduleDirectory?: ReadonlyArray<string>;
                                                              paths?: ReadonlyArray<string>;
                                                              resolver?: string | null;
                                                              rootDir?: string;
                                                              throwIfNotFound?: boolean;
                                                              };

                                                                type JestResolver

                                                                type JestResolver = ResolverSyncObject | ResolverAsyncObject;

                                                                  type PackageJSON

                                                                  type PackageJSON = JSONObject;

                                                                    type ResolveModuleConfig

                                                                    type ResolveModuleConfig = {
                                                                    conditions?: ReadonlyArray<string>;
                                                                    skipNodeResolution?: boolean;
                                                                    paths?: ReadonlyArray<string>;
                                                                    };

                                                                      type SyncResolver

                                                                      type SyncResolver = (path: string, options: ResolverOptions) => string;

                                                                        Package Files (1)

                                                                        Dependencies (8)

                                                                        Dev Dependencies (2)

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

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