@@ -163,6 +163,10 @@ describe("WatchTestCases", () => {
163163 return test ;
164164 }
165165
166+ const globalContext = {
167+ console : console
168+ } ;
169+
166170 function _require ( currentDirectory , module ) {
167171 if ( Array . isArray ( module ) || / ^ \. \. ? \/ / . test ( module ) ) {
168172 let fn ;
@@ -178,11 +182,15 @@ describe("WatchTestCases", () => {
178182 p = path . join ( currentDirectory , module ) ;
179183 content = fs . readFileSync ( p , "utf-8" ) ;
180184 }
181- fn = vm . runInThisContext ( "(function(require, module, exports, __dirname, __filename, it, WATCH_STEP, STATS_JSON, STATE) {" + content + "\n})" , p ) ;
185+ if ( options . target === "web" || options . target === "webworker" ) {
186+ fn = vm . runInNewContext ( "(function(require, module, exports, __dirname, __filename, it, WATCH_STEP, STATS_JSON, STATE, window) {" + content + "\n})" , globalContext , p ) ;
187+ } else {
188+ fn = vm . runInThisContext ( "(function(require, module, exports, __dirname, __filename, it, WATCH_STEP, STATS_JSON, STATE) {" + content + "\n})" , p ) ;
189+ }
182190 const m = {
183191 exports : { }
184192 } ;
185- fn . call ( m . exports , _require . bind ( null , path . dirname ( p ) ) , m , m . exports , path . dirname ( p ) , p , _it , run . name , jsonStats , state ) ;
193+ fn . call ( m . exports , _require . bind ( null , path . dirname ( p ) ) , m , m . exports , path . dirname ( p ) , p , _it , run . name , jsonStats , state , globalContext ) ;
186194 return module . exports ;
187195 } else if ( testConfig . modules && module in testConfig . modules ) {
188196 return testConfig . modules [ module ] ;
@@ -196,7 +204,7 @@ describe("WatchTestCases", () => {
196204 } catch ( e ) { }
197205
198206 if ( testConfig . noTests ) return process . nextTick ( done ) ;
199- _require ( outputDirectory , "./bundle.js" ) ;
207+ _require ( outputDirectory , testConfig . bundlePath || "./bundle.js" ) ;
200208
201209 if ( exportedTests < 1 ) return done ( new Error ( "No tests exported by test case" ) ) ;
202210 runIdx ++ ;
0 commit comments