A framework for building native applications using React
RN: Refactor Jest Default Mocks (#51669)
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
T
Tim Yung committed
1fd9508ecc499df89b086e0c46035f43f6f78ad9
Parent: 5bf7eb8
Committed by Facebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
on 5/29/2025, 2:52:38 PM