Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
### Fixes

- `[jest-core]` Capture execError during `TestScheduler.scheduleTests` and dispatch to reporters ([#13203](https://github.com/facebook/jest/pull/13203))
- `[jest-resolver]` Make sure to resolve module paths after looking at `exports` ([#13242](https://github.com/facebook/jest/pull/13242))
- `[jest-snapshot]` Fix typings of snapshot matchers ([#13240])(https://github.com/facebook/jest/pull/13240))

### Chore & Maintenance
Expand Down
14 changes: 14 additions & 0 deletions packages/jest-resolve/src/__tests__/resolve.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,20 @@ describe('findNodeModule', () => {
);
});

test('supports nested paths with wildcard and no extension', () => {
const result = Resolver.findNodeModule('exports/directory/file', {
basedir: conditionsRoot,
conditions: [],
});

expect(result).toEqual(
path.resolve(
conditionsRoot,
'./node_modules/exports/some-other-directory/file.js',
),
);
});

test('supports nested conditions', () => {
const resultRequire = Resolver.findNodeModule('exports/deeplyNested', {
basedir: conditionsRoot,
Expand Down
6 changes: 1 addition & 5 deletions packages/jest-resolve/src/defaultResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,7 @@ const defaultResolver: SyncResolver = (path, options) => {

const pathToResolve = getPathInModule(path, resolveOptions);

const result =
// if `getPathInModule` doesn't change the path, attempt to resolve it
pathToResolve === path
? resolveSync(pathToResolve, resolveOptions)
: pathToResolve;
const result = resolveSync(pathToResolve, resolveOptions);

// Dereference symlinks to ensure we don't create a separate
// module instance depending on how it was referenced.
Expand Down