RN: Refactor Jest Default Mocks
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
importstatements without worrying about eager initialization of dependencies beforeglobalsis setup. - The ability to verify mocks export the same types as the actual module, using a new Flow-typed
mockhelper 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
This pull request was exported from Phabricator. Differential Revision: D75575421
This pull request was exported from Phabricator. Differential Revision: D75575421
This pull request was exported from Phabricator. Differential Revision: D75575421
This pull request was exported from Phabricator. Differential Revision: D75575421
This pull request was exported from Phabricator. Differential Revision: D75575421
This pull request was exported from Phabricator. Differential Revision: D75575421
This pull request was exported from Phabricator. Differential Revision: D75575421
This pull request has been merged in facebook/react-native@1fd9508ecc499df89b086e0c46035f43f6f78ad9.
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?