Skip to content

Commit

Permalink
fix(testing): use rootDir to resolve files with ts
Browse files Browse the repository at this point in the history
  • Loading branch information
barbados-clemens committed Apr 5, 2023
1 parent ee1f7c1 commit 585fe55
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions packages/jest/plugins/resolver.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { dirname, extname } from 'path';
import { dirname, extname, join } from 'path';
import { resolve as resolveExports } from 'resolve.exports';
import type defaultResolver from 'jest-resolve/build/defaultResolver';

Expand Down Expand Up @@ -81,7 +81,11 @@ module.exports = function (path: string, options: ResolveOptions) {
ts = ts || require('typescript');
compilerSetup = compilerSetup || getCompilerSetup(options.rootDir);
const { compilerOptions, host } = compilerSetup;
return ts.resolveModuleName(path, options.basedir, compilerOptions, host)
.resolvedModule.resolvedFileName;
return ts.resolveModuleName(
path,
join(options.basedir, 'fake-placeholder.ts'),
compilerOptions,
host
).resolvedModule.resolvedFileName;
}
};

0 comments on commit 585fe55

Please sign in to comment.