diff --git a/packages/react-native-renderer/src/__tests__/ReactNativeError-test.internal.js b/packages/react-native-renderer/src/__tests__/ReactNativeError-test.internal.js index 42c07a645a7f8..c3d0254974ff8 100644 --- a/packages/react-native-renderer/src/__tests__/ReactNativeError-test.internal.js +++ b/packages/react-native-renderer/src/__tests__/ReactNativeError-test.internal.js @@ -33,14 +33,13 @@ describe('ReactNativeError', () => { }); it('should throw error if null component registration getter is used', () => { - let error; - try { - createReactNativeComponentClass('View', null); - } catch (e) { - error = e; - } - - expect(error.toString()).toBe('Invariant Violation: View config getter callback must be a function: View (received null)'); + expect(() => { + try { + createReactNativeComponentClass('View', null); + } catch (e) { + throw new Error(e.toString()); + } + }).toThrow('Invariant Violation: View config getter callback must be a function: View (received null)'); }); it('should be able to extract a component stack from a native view', () => {