Skip to content

Fix vacuous package root lookup tests - #2191

Merged
vzaidman merged 1 commit into
react:mainfrom
vzaidman:vzaidman/fix-vacuous-package-root-tests
Nov 6, 2026
Merged

vzaidman merged 1 commit into
react:mainfrom
vzaidman:vzaidman/fix-vacuous-package-root-tests

Conversation

@vzaidman

@vzaidman vzaidman commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Summary

Since #2174, unstable_resolveExportsFromPackageRoot defaults to true in the resolver test context, so the baseline in two package-scope-test.js tests already had the option enabled. Each compared lookups with the option on against lookups with the option on, and could not fail.

The baseline now sets unstable_resolveExportsFromPackageRoot: false explicitly, restoring the off vs. on comparison.

Changelog: [Internal]

Test plan

yarn jest packages/metro-resolver/src/__tests__/package-scope-test.js
Tests:       17 passed, 17 total

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Nov 6, 2026
@vzaidman
vzaidman marked this pull request as ready for review November 6, 2026 13:31
@vzaidman
vzaidman requested a review from robhogan November 6, 2026 13:31
@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown

Metro review: Looks good

Risk: low · Commit: 14970cd · 3 commands run

This is a test-only change. Since #2174, the resolver test context (__tests__/utils.js) turns unstable_resolveExportsFromPackageRoot on by default, so two tests in package-scope-test.js were comparing the option on against the option on. The PR sets the baseline to false. I confirmed with a mutation test that the fixed tests now catch extra lookups and the old versions didn't. No issues found.

No findings.

Verified
  • ✅ yarn jest --no-watchman packages/metro-resolver/src/__tests__/package-scope-test.js — 17/17 pass at head, matching the test plan.
  • ✅ Mutation: in getRootPackageForExports (resolve.js), add an extra context.getPackageForModule call when the option is on, then run the head test file and a copy of the base test file with --verbose (failed as expected) — Both head tests ('package entry point…' and 'package missing from a node_modules directory…') fail under the mutation. The base versions of the same tests pass, which shows they were vacuous before. The mutation and the copied test file were then removed.
  • ✅ yarn eslint packages/metro-resolver/src/__tests__/package-scope-test.js

Not run: No benchmarks or Windows runs: the change is test-only and platform-neutral. No typecheck: only object literals with an existing boolean field changed. I looked at the third comparison test ('package subpath makes no more lookups if package exports are disabled'). The default doesn't affect it, because the option only takes effect when package exports are enabled.

Automated review by Claude. Advisory only: it never approves or blocks, and a maintainer makes the call.

@robhogan robhogan mentioned this pull request Nov 6, 2026
@vzaidman
vzaidman merged commit 8a7f97b into react:main Nov 6, 2026
17 checks passed
@vzaidman
vzaidman deleted the vzaidman/fix-vacuous-package-root-tests branch November 6, 2026 16:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants