diff --git a/packages/jest-resolve/src/fileWalkers.ts b/packages/jest-resolve/src/fileWalkers.ts index 50777ba0fa50..6821310439fb 100644 --- a/packages/jest-resolve/src/fileWalkers.ts +++ b/packages/jest-resolve/src/fileWalkers.ts @@ -28,7 +28,14 @@ function statSyncCached(path: string): IPathType { return result; } - const stat = fs.statSync(path, {throwIfNoEntry: false}); + let stat; + try { + stat = fs.statSync(path, {throwIfNoEntry: false}); + } catch (e: any) { + if (!(e && (e.code === 'ENOENT' || e.code === 'ENOTDIR'))) { + throw e; + } + } if (stat) { if (stat.isFile() || stat.isFIFO()) { diff --git a/packages/jest-runtime/src/__tests__/runtime_require_module.test.js b/packages/jest-runtime/src/__tests__/runtime_require_module.test.js index 639e4c4503f5..46bd064769e8 100644 --- a/packages/jest-runtime/src/__tests__/runtime_require_module.test.js +++ b/packages/jest-runtime/src/__tests__/runtime_require_module.test.js @@ -41,6 +41,7 @@ describe('Runtime requireModule', () => { 'exports', 'filename', 'id', + 'isPreloading', 'loaded', 'path', 'parent', @@ -60,6 +61,7 @@ describe('Runtime requireModule', () => { 'exports', 'filename', 'id', + 'isPreloading', 'loaded', 'path', 'parent',