MCPcopy
hub / github.com/jestjs/jest / loadAndEvaluate

Method loadAndEvaluate

packages/jest-runtime/src/internals/EsmLoader.ts:948–960  ·  view source on GitHub ↗
(from: string, moduleName?: string)

Source from the content-addressed store, hash-verified

946 // Public entry for `Runtime.unstable_importModule`. Runtime keeps the
947 // public method as the override seam; this is the body.
948 async loadAndEvaluate(from: string, moduleName?: string): Promise<unknown> {
949 invariant(
950 runtimeSupportsVmModules,
951 'You need to run with a version of node that supports ES Modules in the VM API. See https://jestjs.io/docs/ecmascript-modules',
952 );
953 const [specifierPath, query] = (moduleName ?? '').split('?');
954 const modulePath = await this.resolution.resolveEsmAsync(
955 from,
956 specifierPath,
957 );
958 const module = await this.loadEsmModule(modulePath, query);
959 return this.linkAndEvaluateModule(module);
960 }
961
962 private async loadEsmModule(
963 modulePath: string,

Callers 1

unstable_importModuleMethod · 0.80

Calls 4

loadEsmModuleMethod · 0.95
linkAndEvaluateModuleMethod · 0.95
invariantFunction · 0.90
resolveEsmAsyncMethod · 0.80

Tested by

no test coverage detected