@@ -19,10 +19,12 @@ type SuiteFunction = ((this: Mocha.Suite) => void)|undefined;
1919function devtoolsTestInterface ( rootSuite : Mocha . Suite ) {
2020 let defaultImplementation : CommonFunctions ;
2121 let mochaGlobals : Mocha . MochaGlobals ;
22+ let mochaRoot : Mocha ;
2223 rootSuite . on (
2324 Mocha . Suite . constants . EVENT_FILE_PRE_REQUIRE ,
2425 ( context : Mocha . MochaGlobals , file : string , mocha : Mocha ) => {
2526 mochaGlobals = context ;
27+ mochaRoot = mocha ;
2628 // Different module outputs between tsc and esbuild.
2729 const defaultFactory = ( 'default' in commonInterface ? commonInterface . default : commonInterface ) ;
2830 defaultImplementation = defaultFactory ( [ rootSuite ] , context , mocha ) as CommonFunctions ;
@@ -47,7 +49,7 @@ function devtoolsTestInterface(rootSuite: Mocha.Suite) {
4749 mochaGlobals . setup = function ( suiteSettings : SuiteSettings ) {
4850 StateProvider . instance . registerSettingsCallback ( suite , suiteSettings ) ;
4951 } ;
50- const it = customIt ( defaultImplementation . test , suite , suite . file || '' ) ;
52+ const it = customIt ( defaultImplementation . test , suite , suite . file || '' , mochaRoot ) ;
5153 // @ts -expect-error Custom interface.
5254 mochaGlobals . it = it ;
5355 } ) ;
@@ -105,7 +107,7 @@ function iterationSuffix(iteration: number): string {
105107 }
106108 return ` (#${ iteration } )` ;
107109}
108- function customIt ( testImplementation : TestFunctions , suite : Mocha . Suite , file : string ) {
110+ function customIt ( testImplementation : TestFunctions , suite : Mocha . Suite , file : string , mocha : Mocha ) {
109111 function instrumentWithState ( fn : E2E . TestAsyncCallbackWithState ) {
110112 const fnWithState = async function ( this : Mocha . Context ) {
111113 return await StateProvider . instance . callWithState ( this , suite , fn ) ;
0 commit comments