Skip to content

Commit f43499c

Browse files
committed
remove dead code
1 parent cbf4676 commit f43499c

File tree

1 file changed

+1
-63
lines changed

1 file changed

+1
-63
lines changed

packages/jest-runtime/src/index.ts

+1-63
Original file line numberDiff line numberDiff line change
@@ -614,69 +614,7 @@ export default class Runtime {
614614
return evaluateSyntheticModule(module);
615615
}
616616

617-
const manualMockOrStub = this._resolver.getMockModule(from, moduleName);
618-
619-
let modulePath =
620-
this._resolver.getMockModule(from, moduleName) ||
621-
this._resolveModule(from, moduleName);
622-
623-
let isManualMock =
624-
manualMockOrStub &&
625-
!this._resolver.resolveStubModuleName(from, moduleName);
626-
if (!isManualMock) {
627-
// If the actual module file has a __mocks__ dir sitting immediately next
628-
// to it, look to see if there is a manual mock for this file.
629-
//
630-
// subDir1/my_module.js
631-
// subDir1/__mocks__/my_module.js
632-
// subDir2/my_module.js
633-
// subDir2/__mocks__/my_module.js
634-
//
635-
// Where some other module does a relative require into each of the
636-
// respective subDir{1,2} directories and expects a manual mock
637-
// corresponding to that particular my_module.js file.
638-
639-
const moduleDir = path.dirname(modulePath);
640-
const moduleFileName = path.basename(modulePath);
641-
const potentialManualMock = path.join(
642-
moduleDir,
643-
'__mocks__',
644-
moduleFileName,
645-
);
646-
if (fs.existsSync(potentialManualMock)) {
647-
isManualMock = true;
648-
modulePath = potentialManualMock;
649-
}
650-
}
651-
if (isManualMock) {
652-
const localModule: InitialModule = {
653-
children: [],
654-
exports: {},
655-
filename: modulePath,
656-
id: modulePath,
657-
loaded: false,
658-
path: modulePath,
659-
};
660-
661-
this._loadModule(
662-
localModule,
663-
from,
664-
moduleName,
665-
modulePath,
666-
undefined,
667-
this._moduleMockRegistry,
668-
);
669-
670-
this._moduleMockRegistry.set(moduleID, localModule.exports);
671-
} else {
672-
// Look for a real module to generate an automock from
673-
this._moduleMockRegistry.set(
674-
moduleID,
675-
this._generateMock(from, moduleName),
676-
);
677-
}
678-
679-
return this._moduleMockRegistry.get(moduleID);
617+
throw new Error('Attempting to import a mock without a factory');
680618
}
681619

682620
requireModule<T = unknown>(

0 commit comments

Comments
 (0)