mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/51669 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. Reviewed By: javache Differential Revision: D75575421 fbshipit-source-id: 98d60e10b753f1505ffdccf5f12f5d3ef306ebb5