Skip to content

Commit be61d1f

Browse files
committed
remove dead code
1 parent 9d7f9cc commit be61d1f

File tree

1 file changed

+1
-64
lines changed

1 file changed

+1
-64
lines changed

packages/jest-runtime/src/index.ts

+1-64
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,6 @@ export default class Runtime {
590590
this.setExport(key, value);
591591
});
592592
},
593-
// should identifier be `node://${moduleName}`?
594593
{context, identifier: moduleName},
595594
);
596595

@@ -599,69 +598,7 @@ export default class Runtime {
599598
return evaluateSyntheticModule(module);
600599
}
601600

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

667604
private getExportsOfCjs(modulePath: Config.Path) {

0 commit comments

Comments
 (0)