@@ -109,6 +109,42 @@ After({ tags: "foo" }, function () {
109109 expectType < Mocha . Context > ( this ) ;
110110} ) ;
111111
112+ expectType < messages . GherkinDocument > ( window . testState . gherkinDocument ) ;
113+ expectType < messages . Pickle [ ] > ( window . testState . pickles ) ;
114+ expectType < messages . Pickle > ( window . testState . pickle ) ;
115+ expectType < messages . PickleStep | undefined > ( window . testState . pickleStep ) ;
116+
117+ /**
118+ * Extending world (example #1)
119+ */
120+ interface MathWorld {
121+ add ( a : number , b : number ) : number ;
122+ }
123+
124+ declare global {
125+ // eslint-disable-next-line @typescript-eslint/no-namespace
126+ namespace Mocha {
127+ // eslint-disable-next-line @typescript-eslint/no-empty-interface
128+ interface Context extends MathWorld { }
129+ }
130+ }
131+
132+ Given ( / f o o / , function ( ) {
133+ expectType < number > ( this . add ( 1 , 2 ) ) ;
134+ } ) ;
135+
136+ When ( / f o o / , function ( ) {
137+ expectType < number > ( this . add ( 1 , 2 ) ) ;
138+ } ) ;
139+
140+ Then ( / f o o / , function ( ) {
141+ expectType < number > ( this . add ( 1 , 2 ) ) ;
142+ } ) ;
143+
144+ /**
145+ * Extending world (example #2)
146+ */
147+
112148interface CustomWorld extends Mocha . Context {
113149 pageDriver : {
114150 navigateTo ( url : string ) : void ;
@@ -129,8 +165,3 @@ Then(/foo/, function (this: CustomWorld, url: string) {
129165 expectType < CustomWorld > ( this ) ;
130166 this . pageDriver . navigateTo ( url ) ;
131167} ) ;
132-
133- expectType < messages . GherkinDocument > ( window . testState . gherkinDocument ) ;
134- expectType < messages . Pickle [ ] > ( window . testState . pickles ) ;
135- expectType < messages . Pickle > ( window . testState . pickle ) ;
136- expectType < messages . PickleStep | undefined > ( window . testState . pickleStep ) ;
0 commit comments