Skip to content

Commit 9d2349a

Browse files
committed
remove dead code
1 parent 6478bb2 commit 9d2349a

File tree

1 file changed

+1
-64
lines changed

1 file changed

+1
-64
lines changed

packages/jest-runtime/src/index.ts

Lines changed: 1 addition & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,6 @@ export default class Runtime {
637637
this.setExport(key, value);
638638
});
639639
},
640-
// should identifier be `node://${moduleName}`?
641640
{context, identifier: moduleName},
642641
);
643642

@@ -646,69 +645,7 @@ export default class Runtime {
646645
return evaluateSyntheticModule(module);
647646
}
648647

649-
const manualMockOrStub = this._resolver.getMockModule(from, moduleName);
650-
651-
let modulePath =
652-
this._resolver.getMockModule(from, moduleName) ||
653-
this._resolveModule(from, moduleName);
654-
655-
let isManualMock =
656-
manualMockOrStub &&
657-
!this._resolver.resolveStubModuleName(from, moduleName);
658-
if (!isManualMock) {
659-
// If the actual module file has a __mocks__ dir sitting immediately next
660-
// to it, look to see if there is a manual mock for this file.
661-
//
662-
// subDir1/my_module.js
663-
// subDir1/__mocks__/my_module.js
664-
// subDir2/my_module.js
665-
// subDir2/__mocks__/my_module.js
666-
//
667-
// Where some other module does a relative require into each of the
668-
// respective subDir{1,2} directories and expects a manual mock
669-
// corresponding to that particular my_module.js file.
670-
671-
const moduleDir = path.dirname(modulePath);
672-
const moduleFileName = path.basename(modulePath);
673-
const potentialManualMock = path.join(
674-
moduleDir,
675-
'__mocks__',
676-
moduleFileName,
677-
);
678-
if (fs.existsSync(potentialManualMock)) {
679-
isManualMock = true;
680-
modulePath = potentialManualMock;
681-
}
682-
}
683-
if (isManualMock) {
684-
const localModule: InitialModule = {
685-
children: [],
686-
exports: {},
687-
filename: modulePath,
688-
id: modulePath,
689-
loaded: false,
690-
path: modulePath,
691-
};
692-
693-
this._loadModule(
694-
localModule,
695-
from,
696-
moduleName,
697-
modulePath,
698-
undefined,
699-
this._moduleMockRegistry,
700-
);
701-
702-
this._moduleMockRegistry.set(moduleID, localModule.exports);
703-
} else {
704-
// Look for a real module to generate an automock from
705-
this._moduleMockRegistry.set(
706-
moduleID,
707-
this._generateMock(from, moduleName),
708-
);
709-
}
710-
711-
return this._moduleMockRegistry.get(moduleID);
648+
throw new Error('Attempting to import a mock without a factory');
712649
}
713650

714651
private getExportsOfCjs(modulePath: Config.Path) {

0 commit comments

Comments
 (0)