@@ -468,7 +468,12 @@ declare namespace CodeceptJS {
468468 // Could get extended by user generated typings
469469 interface Methods extends ActorStatic { }
470470 interface I { }
471- interface IHook { }
471+ interface IHook {
472+ ( callback : HookCallback ) : HookConfig
473+ }
474+ interface IHookSuite {
475+ ( callback : HookSuiteCallback ) : HookConfig
476+ }
472477 interface IScenario { }
473478 interface IFeature {
474479 ( title : string , opts ?: { [ key : string ] : any } ) : FeatureConfig
@@ -508,8 +513,22 @@ declare namespace CodeceptJS {
508513
509514 type StringOrSecret = string | CodeceptJS . Secret
510515
516+ interface GherkinCallback {
517+ ( test : Test ) : void | Promise < void >
518+ }
519+ interface GherkinEventEmitter { }
520+ interface GherkinHook {
521+ ( callback : GherkinCallback ) : GherkinEventEmitter
522+ }
511523 interface HookCallback {
512- ( args : SupportObject ) : void | Promise < void >
524+ // `suite` has type Mocha.Suite if hook (Background/Before/After) is called before `Feature()`
525+ // `suite` has type CodeceptJS.Suite if hook is called after `Feature()`
526+ ( args : SupportObject & { suite : Mocha . Suite ; test : Test } ) : void | Promise < void >
527+ }
528+ interface HookSuiteCallback {
529+ // `suite` has type Mocha.Suite if hook (BeforeSuite/AfterSuite) is called before `Feature()`
530+ // `suite` has type CodeceptJS.Suite if hook is called after `Feature()`
531+ ( args : SupportObject & { suite : Mocha . Suite } ) : void | Promise < void >
513532 }
514533 interface Scenario extends IScenario {
515534 only : IScenario
@@ -530,9 +549,6 @@ declare namespace CodeceptJS {
530549 ( title : string , callback ?: HookCallback ) : ScenarioConfig
531550 ( title : string , opts : { [ key : string ] : any } , callback : HookCallback ) : ScenarioConfig
532551 }
533- interface IHook {
534- ( callback : HookCallback ) : HookConfig
535- }
536552
537553 interface Globals {
538554 codeceptjs : typeof codeceptjs
@@ -580,11 +596,13 @@ declare function xData(data: any): CodeceptJS.IData
580596declare function DefineParameterType ( options : CodeceptJS . IParameterTypeDefinition < any > ) : void
581597
582598// Hooks
583- declare const BeforeSuite : CodeceptJS . IHook
584- declare const AfterSuite : CodeceptJS . IHook
599+ declare const BeforeSuite : CodeceptJS . IHookSuite
600+ declare const AfterSuite : CodeceptJS . IHookSuite
585601declare const Background : CodeceptJS . IHook
586602declare const Before : CodeceptJS . IHook
587603declare const After : CodeceptJS . IHook
604+ declare const GherkinBefore : CodeceptJS . GherkinHook
605+ declare const GherkinAfter : CodeceptJS . GherkinHook
588606
589607// Plugins
590608declare const __ : any
0 commit comments