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

Method findManualMock

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

Source from the content-addressed store, hash-verified

136 // respective subDir{1,2} directories and expects a manual mock
137 // corresponding to that particular my_module.js file.
138 findManualMock(from: string, moduleName: string): string | null {
139 // Normalize core specifiers (`node:fs` → `fs`) before building the cache
140 // key so the two forms share an entry instead of populating two.
141 const canonicalName = this.isCoreModule(moduleName)
142 ? this.normalizeCoreModuleSpecifier(moduleName)
143 : moduleName;
144 const cacheKey = `${from}\0${canonicalName}`;
145 let result = this.manualMockCache.get(cacheKey);
146 if (result === undefined) {
147 result = this.computeManualMock(from, canonicalName);
148 this.manualMockCache.set(cacheKey, result);
149 }
150 return result;
151 }
152
153 private computeManualMock(from: string, moduleName: string): string | null {
154 if (this.isCoreModule(moduleName)) {

Callers 2

_requireMockWithIdMethod · 0.80
Resolution.test.tsFile · 0.80

Calls 5

isCoreModuleMethod · 0.95
computeManualMockMethod · 0.95
getMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected