diff --git a/packages/react-native/Libraries/Core/__mocks__/NativeExceptionsManager.js b/packages/react-native/Libraries/Core/__mocks__/NativeExceptionsManager.js new file mode 100644 index 00000000000..a43017ce012 --- /dev/null +++ b/packages/react-native/Libraries/Core/__mocks__/NativeExceptionsManager.js @@ -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); diff --git a/packages/react-native/jest/__tests__/setup-test.js b/packages/react-native/jest/__tests__/setup-test.js new file mode 100644 index 00000000000..cc06b3dcf6d --- /dev/null +++ b/packages/react-native/jest/__tests__/setup-test.js @@ -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, + ); +}); diff --git a/packages/react-native/jest/setup.js b/packages/react-native/jest/setup.js index 3865229af71..c542ef38f8b 100644 --- a/packages/react-native/jest/setup.js +++ b/packages/react-native/jest/setup.js @@ -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: {