diff --git a/packages/rn-tester/js/examples/TurboModule/NativeCxxModuleExampleExample.js b/packages/rn-tester/js/examples/TurboModule/NativeCxxModuleExampleExample.js index f4135cc5b5ffc3..189c3a5fd21475 100644 --- a/packages/rn-tester/js/examples/TurboModule/NativeCxxModuleExampleExample.js +++ b/packages/rn-tester/js/examples/TurboModule/NativeCxxModuleExampleExample.js @@ -55,7 +55,9 @@ type Examples = | 'rejectPromise' | 'voidFunc' | 'optionalArgs' - | 'emitDeviceEvent' + | 'emitDeviceEvent'; + +type ErrorExamples = | 'voidFuncThrows' | 'getObjectThrows' | 'promiseThrows' @@ -131,6 +133,10 @@ class NativeCxxModuleExampleExample extends React.Component<{||}, State> { }); NativeCxxModuleExample?.emitCustomDeviceEvent(CUSTOM_EVENT_TYPE); }, + }; + + // $FlowFixMe[missing-local-annot] + _errorTests = { voidFuncThrows: () => { try { NativeCxxModuleExample?.voidFuncThrows(); @@ -202,7 +208,7 @@ class NativeCxxModuleExampleExample extends React.Component<{||}, State> { })); } - _renderResult(name: Examples): React.Node { + _renderResult(name: Examples | ErrorExamples): React.Node { const result = this.state.testResults[name] || {}; return ( @@ -231,7 +237,7 @@ class NativeCxxModuleExampleExample extends React.Component<{||}, State> { this._setResult(item, this._tests[item]()), ) }> - Run all tests + Run function call tests this.setState({testResults: {}})} @@ -254,6 +260,24 @@ class NativeCxxModuleExampleExample extends React.Component<{||}, State> { )} /> + + Report errors tests + + item} + renderItem={({item}: {item: ErrorExamples, ...}) => ( + + this._setResult(item, this._errorTests[item]())}> + {item} + + {this._renderResult(item)} + + )} + /> ); }