react-native icon indicating copy to clipboard operation
react-native copied to clipboard

RN: Refactor Jest Default Mocks

Open yungsters opened this issue 8 months ago • 7 comments

Summary: Refactors the default mocks initialized in packages/react-native/jest/setup.js so that each mock is defined in its own file.

This provides several benefits, including:

  • The ability to use import statements without worrying about eager initialization of dependencies before globals is setup.
  • The ability to verify mocks export the same types as the actual module, using a new Flow-typed mock helper function.
  • The ergonomic of implementing mocks with more complex logic, without having to split them out into a separate module (e.g. mockModal, mockScrollView).

As part of this migration, I also fixed any minor discrepancies to match the actual type definition. For more involved discrepancies (e.g. missing methods), I added type suppressions for now to minimize breaking changes.

Changelog: [General][Changed] - Improved default mocking for Jest unit tests.

Differential Revision: D75575421

yungsters avatar May 29 '25 03:05 yungsters

This pull request was exported from Phabricator. Differential Revision: D75575421

facebook-github-bot avatar May 29 '25 03:05 facebook-github-bot

This pull request was exported from Phabricator. Differential Revision: D75575421

facebook-github-bot avatar May 29 '25 04:05 facebook-github-bot

This pull request was exported from Phabricator. Differential Revision: D75575421

facebook-github-bot avatar May 29 '25 04:05 facebook-github-bot

This pull request was exported from Phabricator. Differential Revision: D75575421

facebook-github-bot avatar May 29 '25 05:05 facebook-github-bot

This pull request was exported from Phabricator. Differential Revision: D75575421

facebook-github-bot avatar May 29 '25 05:05 facebook-github-bot

This pull request was exported from Phabricator. Differential Revision: D75575421

facebook-github-bot avatar May 29 '25 06:05 facebook-github-bot

This pull request was exported from Phabricator. Differential Revision: D75575421

facebook-github-bot avatar May 29 '25 06:05 facebook-github-bot

This pull request has been merged in facebook/react-native@1fd9508ecc499df89b086e0c46035f43f6f78ad9.

facebook-github-bot avatar May 29 '25 14:05 facebook-github-bot

This pull request was successfully merged by @yungsters in 1fd9508ecc499df89b086e0c46035f43f6f78ad9

When will my fix make it into a release? | How to file a pick request?

react-native-bot avatar May 29 '25 14:05 react-native-bot