File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -302,6 +302,37 @@ describe('React', () => {
302
302
303
303
spy . mockRestore ( )
304
304
} )
305
+
306
+ it ( 're-throws errors from the selector that only occur during rendering' , ( ) => {
307
+ const spy = jest . spyOn ( console , 'error' ) . mockImplementation ( ( ) => { } )
308
+
309
+ const Parent = ( ) => {
310
+ const count = useSelector ( s => s . count )
311
+ return < Child parentCount = { count } />
312
+ }
313
+
314
+ const Child = ( { parentCount } ) => {
315
+ const result = useSelector ( ( { count } ) => {
316
+ if ( parentCount > 0 ) {
317
+ throw new Error ( )
318
+ }
319
+
320
+ return count + parentCount
321
+ } )
322
+
323
+ return < div > { result } </ div >
324
+ }
325
+
326
+ rtl . render (
327
+ < ProviderMock store = { store } >
328
+ < Parent />
329
+ </ ProviderMock >
330
+ )
331
+
332
+ expect ( ( ) => store . dispatch ( { type : '' } ) ) . toThrowError ( )
333
+
334
+ spy . mockRestore ( )
335
+ } )
305
336
} )
306
337
307
338
describe ( 'error handling for invalid arguments' , ( ) => {
You can’t perform that action at this time.
0 commit comments