From eac6673428aaceee7a41b4ccf363f8b8c6916c86 Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Wed, 23 Dec 2020 16:46:01 +0100 Subject: [PATCH] remove dead code --- packages/jest-runtime/src/index.ts | 65 +----------------------------- 1 file changed, 1 insertion(+), 64 deletions(-) diff --git a/packages/jest-runtime/src/index.ts b/packages/jest-runtime/src/index.ts index 1b1ecdd55a42..0e4527830071 100644 --- a/packages/jest-runtime/src/index.ts +++ b/packages/jest-runtime/src/index.ts @@ -596,7 +596,6 @@ export default class Runtime { this.setExport(key, value); }); }, - // should identifier be `node://${moduleName}`? {context, identifier: moduleName}, ); @@ -605,69 +604,7 @@ export default class Runtime { return evaluateSyntheticModule(module); } - const manualMockOrStub = this._resolver.getMockModule(from, moduleName); - - let modulePath = - this._resolver.getMockModule(from, moduleName) || - this._resolveModule(from, moduleName); - - let isManualMock = - manualMockOrStub && - !this._resolver.resolveStubModuleName(from, moduleName); - if (!isManualMock) { - // If the actual module file has a __mocks__ dir sitting immediately next - // to it, look to see if there is a manual mock for this file. - // - // subDir1/my_module.js - // subDir1/__mocks__/my_module.js - // subDir2/my_module.js - // subDir2/__mocks__/my_module.js - // - // Where some other module does a relative require into each of the - // respective subDir{1,2} directories and expects a manual mock - // corresponding to that particular my_module.js file. - - const moduleDir = path.dirname(modulePath); - const moduleFileName = path.basename(modulePath); - const potentialManualMock = path.join( - moduleDir, - '__mocks__', - moduleFileName, - ); - if (fs.existsSync(potentialManualMock)) { - isManualMock = true; - modulePath = potentialManualMock; - } - } - if (isManualMock) { - const localModule: InitialModule = { - children: [], - exports: {}, - filename: modulePath, - id: modulePath, - loaded: false, - path: modulePath, - }; - - this._loadModule( - localModule, - from, - moduleName, - modulePath, - undefined, - this._moduleMockRegistry, - ); - - this._moduleMockRegistry.set(moduleID, localModule.exports); - } else { - // Look for a real module to generate an automock from - this._moduleMockRegistry.set( - moduleID, - this._generateMock(from, moduleName), - ); - } - - return this._moduleMockRegistry.get(moduleID); + throw new Error('Attempting to import a mock without a factory'); } private getExportsOfCjs(modulePath: Config.Path) {