File tree Expand file tree Collapse file tree 2 files changed +481
-20
lines changed
Expand file tree Collapse file tree 2 files changed +481
-20
lines changed Original file line number Diff line number Diff line change @@ -267,6 +267,8 @@ async function callAroundHooks<THook extends Function>(
267267 return
268268 }
269269
270+ const hookErrors : unknown [ ] = [ ]
271+
270272 const createTimeoutPromise = (
271273 timeout : number ,
272274 phase : 'setup' | 'teardown' ,
@@ -352,23 +354,13 @@ async function callAroundHooks<THook extends Function>(
352354 setupTimeout . clear ( )
353355
354356 // Run inner hooks - don't time this against our teardown timeout
355- let nextError : { value : unknown } | undefined
356- try {
357- await runNextHook ( index + 1 )
358- }
359- catch ( value ) {
360- nextError = { value }
361- }
357+ await runNextHook ( index + 1 ) . catch ( e => hookErrors . push ( e ) )
362358
363359 // Start teardown timer after inner hooks complete - only times this hook's teardown code
364360 teardownTimeout = createTimeoutPromise ( timeout , 'teardown' , stackTraceError )
365361
366362 // Signal that use() is returning (teardown phase starting)
367363 resolveUseReturned ( )
368-
369- if ( nextError ) {
370- throw nextError . value
371- }
372364 }
373365
374366 // Start setup timeout
@@ -422,7 +414,11 @@ async function callAroundHooks<THook extends Function>(
422414 }
423415 }
424416
425- await runNextHook ( 0 )
417+ await runNextHook ( 0 ) . catch ( e => hookErrors . push ( e ) )
418+
419+ if ( hookErrors . length > 0 ) {
420+ throw hookErrors
421+ }
426422}
427423
428424async function callAroundAllHooks (
You can’t perform that action at this time.
0 commit comments