Skip to content

Commit

Permalink
handle target being .
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB committed Sep 8, 2019
1 parent 42795d6 commit 240e0bf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 7 additions & 5 deletions packages/jest-resolve/src/__tests__/resolve.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,13 @@ describe('resolveModule', () => {
extensions: ['.js'],
} as ResolverConfig);
const mocksDirectory = path.resolve(__dirname, '../__mocks__');
const resolved = resolver.resolveModule(
path.join(mocksDirectory, 'foo/foo.js'),
'./',
);
expect(resolved).toBe(path.join(mocksDirectory, 'foo/index.js'));
const fooSlashFoo = path.join(mocksDirectory, 'foo/foo.js');
const fooSlashIndex = path.join(mocksDirectory, 'foo/index.js');

const resolvedWithSlash = resolver.resolveModule(fooSlashFoo, './');
const resolvedWithDot = resolver.resolveModule(fooSlashFoo, '.');
expect(resolvedWithSlash).toBe(fooSlashIndex);
expect(resolvedWithSlash).toBe(resolvedWithDot);
});
});

Expand Down
2 changes: 1 addition & 1 deletion packages/jest-resolve/src/defaultResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ function resolveSync(
if (REGEX_RELATIVE_IMPORT.test(target)) {
// resolve relative import
let resolveTarget = path.resolve(basedir, target);
if (target === '..' || target.endsWith('/')) {
if (target === '.' || target === '..' || target.endsWith('/')) {
resolveTarget += '/';
}
const result = tryResolve(resolveTarget);
Expand Down

0 comments on commit 240e0bf

Please sign in to comment.