@@ -359,17 +359,19 @@ type AfterEachInjectedSuite = {
359359} ;
360360
361361/**
362- * Registers an after (all or each) hook to kill test shells started during the hooks or tests
362+ * Registers an after (all or each) hook to kill test shells started during the hooks or tests.
363+ * You don't have to call this from tests, but you can if you want to register an after (each) hook
364+ * which runs after the shells have been killed.
363365 */
364- function ensureAfterHook (
366+ export function ensureTestShellAfterHook (
365367 hookName : 'afterEach' ,
366368 suite : Mocha . Suite
367369) : asserts suite is AfterEachInjectedSuite & Mocha . Suite ;
368- function ensureAfterHook (
370+ export function ensureTestShellAfterHook (
369371 hookName : 'afterAll' ,
370372 suite : Mocha . Suite
371373) : asserts suite is AfterAllInjectedSuite & Mocha . Suite ;
372- function ensureAfterHook (
374+ export function ensureTestShellAfterHook (
373375 hookName : 'afterEach' | 'afterAll' ,
374376 suite : Partial < AfterAllInjectedSuite & AfterEachInjectedSuite > & Mocha . Suite
375377) : void {
@@ -409,19 +411,19 @@ Mocha.Context.prototype.startTestShell = function (
409411 runnable . originalTitle === '"before each" hook' ||
410412 runnable . originalTitle === '"after each" hook'
411413 ) {
412- ensureAfterHook ( 'afterEach' , parent ) ;
414+ ensureTestShellAfterHook ( 'afterEach' , parent ) ;
413415 parent [ TEST_SHELLS_AFTER_EACH ] . add ( shell ) ;
414416 } else if (
415417 runnable . originalTitle === '"before all" hook' ||
416418 runnable . originalTitle === '"after all" hook'
417419 ) {
418- ensureAfterHook ( 'afterAll' , parent ) ;
420+ ensureTestShellAfterHook ( 'afterAll' , parent ) ;
419421 parent [ TEST_SHELLS_AFTER_ALL ] . add ( shell ) ;
420422 } else {
421423 throw new Error ( `Unexpected ${ runnable . originalTitle || runnable . title } ` ) ;
422424 }
423425 } else if ( runnable instanceof Mocha . Test ) {
424- ensureAfterHook ( 'afterEach' , parent ) ;
426+ ensureTestShellAfterHook ( 'afterEach' , parent ) ;
425427 parent [ TEST_SHELLS_AFTER_EACH ] . add ( shell ) ;
426428 } else {
427429 throw new Error ( 'Unexpected Runnable: Expected a Hook or a Test' ) ;
0 commit comments