Skip to content

Add getMockImplementation to Jest libdef and guard its use in Server test - #2163

Merged
vzaidman merged 1 commit into
react:mainfrom
vzaidman:fixup-2056-nullthrows
Nov 3, 2026
Merged

vzaidman merged 1 commit into
react:mainfrom
vzaidman:fixup-2056-nullthrows

Conversation

@vzaidman

@vzaidman vzaidman commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Follow-up to #2056 (Add the virtual: module path namespace), which is now merged.

flow-typed/jest.js did not declare JestMockFn.getMockImplementation(), so the call in the Server test added by #2056 was hidden behind a $FlowFixMe[prop-missing]. The internal Flow libdef does declare it as returning void | function, so the same code fails internally with not-a-function at Server-test.js:810.

This PR:

  • Declares getMockImplementation() in flow-typed/jest.js, matching the internal libdef.
  • Guards the call in packages/metro/src/Server/tests/Server-test.js with nullthrows (already imported in that file) and removes the now-obsolete $FlowFixMe.

Validation on this branch:

  • OSS Flow focus-check on Server-test.js reproduces the exact internal not-a-function error with only the libdef change, and reports 0 errors with both changes.
  • jest Server-test.js -t 'marks the url-server source path of a virtual module': 1 passed.
  • prettier --check on both changed files: pass.

Changelog: [Internal]

…test

flow-typed/jest.js declares getMockImplementation() returning void | function, matching the internal libdef. Guard the Server test call with nullthrows.
@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 3, 2026

@robhogan robhogan left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@vzaidman
vzaidman merged commit c446901 into react:main Nov 3, 2026
15 checks passed
@vzaidman
vzaidman deleted the fixup-2056-nullthrows branch November 3, 2026 18:29
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. needs-meta-import

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants