File tree 1 file changed +20
-0
lines changed
1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -187,6 +187,26 @@ describe('<ErrorBoundary/>', () => {
187
187
await waitFor ( ( ) => expect ( screen . queryByText ( `${ ERROR_MESSAGE } of Parent` ) ) . toBeInTheDocument ( ) )
188
188
} )
189
189
190
+ it ( 'should re-throw error if not shouldCatch error in children without rendering fallback' , async ( ) => {
191
+ const onErrorParent = vi . fn ( )
192
+ const onErrorChild = vi . fn ( )
193
+ const Fallback = vi . fn ( )
194
+
195
+ render (
196
+ < ErrorBoundary fallback = { ( { error } ) => < > { error . message } of Parent</ > } onError = { onErrorParent } >
197
+ < ErrorBoundary shouldCatch = { false } fallback = { Fallback } onError = { onErrorChild } >
198
+ { createElement ( ( ) => {
199
+ throw new Error ( ERROR_MESSAGE )
200
+ } ) }
201
+ </ ErrorBoundary >
202
+ </ ErrorBoundary >
203
+ )
204
+
205
+ expect ( onErrorChild ) . toBeCalledTimes ( 0 )
206
+ expect ( onErrorParent ) . toBeCalledTimes ( 1 )
207
+ await waitFor ( ( ) => expect ( screen . queryByText ( `${ ERROR_MESSAGE } of Parent` ) ) . toBeInTheDocument ( ) )
208
+ } )
209
+
190
210
it . each ( [
191
211
{
192
212
childCalledTimes : 0 ,
You can’t perform that action at this time.
0 commit comments