diff --git a/packages/jest-resolve/src/defaultResolver.ts b/packages/jest-resolve/src/defaultResolver.ts index ee53502ece4b..c289c4b2fd9d 100644 --- a/packages/jest-resolve/src/defaultResolver.ts +++ b/packages/jest-resolve/src/defaultResolver.ts @@ -120,12 +120,13 @@ export default function defaultResolver( const pathToResolve = getPathInModule(path, resolveOptions); - const result = isAbsolute(pathToResolve) - ? pathToResolve - : resolveSync(pathToResolve, { - ...resolveOptions, - packageFilter: createPackageFilter(pathToResolve, options), - }); + const result = + pathToResolve === path + ? resolveSync(pathToResolve, { + ...resolveOptions, + packageFilter: createPackageFilter(pathToResolve, options), + }) + : pathToResolve; // Dereference symlinks to ensure we don't create a separate // module instance depending on how it was referenced.