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

Method computeManualMock

packages/jest-runtime/src/internals/Resolution.ts:153–168  ·  view source on GitHub ↗
(from: string, moduleName: string)

Source from the content-addressed store, hash-verified

151 }
152
153 private computeManualMock(from: string, moduleName: string): string | null {
154 if (this.isCoreModule(moduleName)) {
155 return this.getCjsMockModule(from, moduleName);
156 }
157
158 const rootMock = this.getCjsMockModule(from, moduleName);
159 if (rootMock) return rootMock;
160
161 const modulePath = this.resolveCjs(from, moduleName);
162 const sibling = path.join(
163 path.dirname(modulePath),
164 '__mocks__',
165 path.basename(modulePath),
166 );
167 return fs.existsSync(sibling) ? sibling : null;
168 }
169
170 resolveCjsStub(from: string, moduleName: string): string | null {
171 return this.resolver.resolveStubModuleName(from, moduleName, {

Callers 1

findManualMockMethod · 0.95

Calls 3

isCoreModuleMethod · 0.95
getCjsMockModuleMethod · 0.95
resolveCjsMethod · 0.95

Tested by

no test coverage detected