Skip to content

Commit

Permalink
refactor(metro-resolver): more descriptive assertions in should resol…
Browse files Browse the repository at this point in the history
…ve exports target directly tests (#1240)

Summary:
This PR adds comments to assertions in tests that check that neither `sourceExts` or `platformExts` are expanded when matching exports target directly, which was suggested inside of #1236 by huntie. The assertions rely on using `[nonstrict]` fallback mechanism as there is no other way to test this functionality right now because `strict` mode is not implemented.

Changelog: [Internal] Refactor Package Exports `sourceExts` and `platformExts` tests that rely on fallback

Pull Request resolved: #1240

Test Plan: - [x] - all tests pass

Reviewed By: hoxyq

Differential Revision: D55427364

Pulled By: huntie

fbshipit-source-id: 8a36469508c67406e721b0300383d6b18add3ad2
  • Loading branch information
jbroma authored and facebook-github-bot committed Mar 28, 2024
1 parent b18bc62 commit 3606983
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/metro-resolver/src/__tests__/package-exports-test.js
Expand Up @@ -216,7 +216,6 @@ describe('with package exports resolution enabled', () => {
...baseContext,
...createPackageAccessors({
'/root/node_modules/test-pkg/package.json': {
main: 'index-main.js',
exports: './index-exports.js',
},
}),
Expand All @@ -225,14 +224,16 @@ describe('with package exports resolution enabled', () => {
test('without expanding `sourceExts`', () => {
expect(Resolver.resolve(context, 'test-pkg', null)).toEqual({
type: 'sourceFile',
filePath: '/root/node_modules/test-pkg/index-main.js',
// [nonstrict] Falls back to index.js based on file resolution
filePath: '/root/node_modules/test-pkg/index.js',
});
});

test('without expanding platform-specific extensions', () => {
expect(Resolver.resolve(context, 'test-pkg', 'ios')).toEqual({
type: 'sourceFile',
filePath: '/root/node_modules/test-pkg/index-main.js',
// [nonstrict] Falls back to index.js based on file resolution
filePath: '/root/node_modules/test-pkg/index.js',
});
});

Expand Down

0 comments on commit 3606983

Please sign in to comment.