mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
RN: Cleanup NativeExceptionsManager Mock (#37074)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/37074 I am exploring ways of cleaning up the React Native Jest `setup.js` logic so that we can enable Flow and make it easier to maintain. This does a few things: - Create a new Jest test to verify that mocking works as expected (i.e. `jest.mock(X)` and `import ... from 'X'` does the right thing). - Move the mock implementation for `NativeExceptionsManager` into a `__mocks__` directory that Jest can find automatically. - Add `flow strict` and fill out the missing implementation details of the `NativeExceptionsManager` mock. Changelog: [General][Added] - Added missing methods to `NativeExceptionsManager` mock in Jest Reviewed By: fkgozali Differential Revision: D45244175 fbshipit-source-id: 0f4c8f873f93304509b80a13ed52e96265d10a42
This commit is contained in:
committed by
Facebook GitHub Bot
parent
a92c5049ba
commit
ba927004c5
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @flow strict
|
||||
* @format
|
||||
* @oncall react_native
|
||||
*/
|
||||
|
||||
import typeof NativeExceptionsManager from '../NativeExceptionsManager';
|
||||
|
||||
export default ({
|
||||
reportFatalException: jest.fn(),
|
||||
reportSoftException: jest.fn(),
|
||||
updateExceptionMessage: jest.fn(),
|
||||
dismissRedbox: jest.fn(),
|
||||
reportException: jest.fn(),
|
||||
}: NativeExceptionsManager);
|
||||
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @flow strict
|
||||
* @format
|
||||
* @oncall react_native
|
||||
*/
|
||||
|
||||
import NativeExceptionsManager from '../../Libraries/Core/NativeExceptionsManager';
|
||||
|
||||
test('NativeExceptionsManager is a mock', () => {
|
||||
expect(jest.isMockFunction(NativeExceptionsManager.reportException)).toBe(
|
||||
true,
|
||||
);
|
||||
});
|
||||
Vendored
+1
-6
@@ -58,12 +58,7 @@ Object.defineProperties(global, {
|
||||
|
||||
jest
|
||||
.mock('../Libraries/Core/InitializeCore', () => {})
|
||||
.mock('../Libraries/Core/NativeExceptionsManager', () => ({
|
||||
__esModule: true,
|
||||
default: {
|
||||
reportException: jest.fn(),
|
||||
},
|
||||
}))
|
||||
.mock('../Libraries/Core/NativeExceptionsManager')
|
||||
.mock('../Libraries/ReactNative/UIManager', () => ({
|
||||
AndroidViewPager: {
|
||||
Commands: {
|
||||
|
||||
Reference in New Issue
Block a user