jest-resolve
- Version 29.7.0
- Published
- 65.7 kB
- 9 dependencies
- MIT license
Install
npm i jest-resolve
yarn add jest-resolve
pnpm add jest-resolve
Overview
Overview not available.
Index
Variables
Functions
Classes
Resolver
- clearDefaultResolverCache()
- findNodeModule()
- findNodeModuleAsync()
- getGlobalPaths()
- getMockModule()
- getMockModuleAsync()
- getModule()
- getModuleID()
- getModuleIDAsync()
- getModulePath()
- getModulePaths()
- getPackage()
- isCoreModule()
- ModuleNotFoundError
- resolveModule()
- resolveModuleAsync()
- resolveModuleFromDirIfExists()
- resolveModuleFromDirIfExistsAsync()
- resolveStubModuleName()
- resolveStubModuleNameAsync()
- tryCastModuleNotFoundError()
- unstable_shouldLoadAsEsm
Type Aliases
Variables
variable defaultResolver
const defaultResolver: SyncResolver;
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 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) => string | null;
method getMockModuleAsync
getMockModuleAsync: (from: string, name: string) => Promise<string | null>;
method getModule
getModule: (name: string) => string | null;
method getModuleID
getModuleID: ( virtualMocks: Map<string, boolean>, from: string, moduleName?: string, options?: ResolveModuleConfig) => string;
method getModuleIDAsync
getModuleIDAsync: ( virtualMocks: Map<string, boolean>, from: string, moduleName?: string, 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 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) => string | null;
method resolveStubModuleNameAsync
resolveStubModuleNameAsync: ( from: string, moduleName: string) => Promise<string | null>;
method tryCastModuleNotFoundError
static tryCastModuleNotFoundError: ( error: unknown) => ModuleNotFoundError | null;
Type Aliases
type AsyncResolver
type AsyncResolver = (path: string, options: ResolverOptions) => Promise<string>;
type FindNodeModuleConfig
type FindNodeModuleConfig = { basedir: string; conditions?: Array<string>; extensions?: Array<string>; moduleDirectory?: Array<string>; paths?: Array<string>; resolver?: string | null; rootDir?: string; throwIfNotFound?: boolean;};
type JestResolver
type JestResolver = ResolverSyncObject | ResolverAsyncObject;
type PackageFilter
type PackageFilter = (pkg: PackageJSON, file: string, dir: string) => PackageJSON;
Allows transforming parsed
package.json
contents.Parameter pkg
Parsed
package.json
contents.Parameter file
Path to
package.json
file.Parameter dir
Directory that contains the
package.json
.Returns
Transformed
package.json
contents.
type PackageJSON
type PackageJSON = JSONObject;
type PathFilter
type PathFilter = (pkg: PackageJSON, path: string, relativePath: string) => string;
Allows transforming a path within a package.
Parameter pkg
Parsed
package.json
contents.Parameter path
Path being resolved.
Parameter relativePath
Path relative from the
package.json
location.Returns
Relative path that will be joined from the
package.json
location.
type ResolveModuleConfig
type ResolveModuleConfig = { conditions?: Array<string>; skipNodeResolution?: boolean; paths?: Array<string>;};
type ResolverOptions
type ResolverOptions = { /** Directory to begin resolving from. */ basedir: string; /** List of export conditions. */ conditions?: Array<string>; /** Instance of default resolver. */ defaultResolver: typeof defaultResolver; /** List of file extensions to search in order. */ extensions?: Array<string>; /** * List of directory names to be looked up for modules recursively. * * @defaultValue * The default is `['node_modules']`. */ moduleDirectory?: Array<string>; /** * List of `require.paths` to use if nothing is found in `node_modules`. * * @defaultValue * The default is `undefined`. */ paths?: Array<string>; /** Allows transforming parsed `package.json` contents. */ packageFilter?: PackageFilter; /** Allows transforms a path within a package. */ pathFilter?: PathFilter; /** Current root directory. */ rootDir?: string;};
type SyncResolver
type SyncResolver = (path: string, options: ResolverOptions) => string;
Package Files (1)
Dependencies (9)
Dev Dependencies (5)
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto 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>
- Updated .
Package analyzed in 3289 ms. - Missing or incorrect documentation? Open an issue for this package.