Skip to content

Commit

Permalink
handle target being .
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB committed Feb 5, 2020
1 parent c6bac20 commit c4c2ad4
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
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
Expand Up @@ -69,7 +69,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 c4c2ad4

Please sign in to comment.