@@ -155,6 +155,10 @@ describe("WatchTestCases", () => {
155155 return test ;
156156 }
157157
158+ const globalContext = {
159+ console : console
160+ } ;
161+
158162 function _require ( currentDirectory , module ) {
159163 if ( Array . isArray ( module ) || / ^ \. \. ? \/ / . test ( module ) ) {
160164 let fn ;
@@ -170,11 +174,15 @@ describe("WatchTestCases", () => {
170174 p = path . join ( currentDirectory , module ) ;
171175 content = fs . readFileSync ( p , "utf-8" ) ;
172176 }
173- fn = vm . runInThisContext ( "(function(require, module, exports, __dirname, __filename, it, WATCH_STEP, STATS_JSON, STATE) {" + content + "\n})" , p ) ;
177+ if ( options . target === "web" || options . target === "webworker" ) {
178+ fn = vm . runInNewContext ( "(function(require, module, exports, __dirname, __filename, it, WATCH_STEP, STATS_JSON, STATE, window) {" + content + "\n})" , globalContext , p ) ;
179+ } else {
180+ fn = vm . runInThisContext ( "(function(require, module, exports, __dirname, __filename, it, WATCH_STEP, STATS_JSON, STATE) {" + content + "\n})" , p ) ;
181+ }
174182 const m = {
175183 exports : { }
176184 } ;
177- fn . call ( m . exports , _require . bind ( null , path . dirname ( p ) ) , m , m . exports , path . dirname ( p ) , p , _it , run . name , jsonStats , state ) ;
185+ fn . call ( m . exports , _require . bind ( null , path . dirname ( p ) ) , m , m . exports , path . dirname ( p ) , p , _it , run . name , jsonStats , state , globalContext ) ;
178186 return module . exports ;
179187 } else if ( testConfig . modules && module in testConfig . modules ) {
180188 return testConfig . modules [ module ] ;
@@ -188,7 +196,7 @@ describe("WatchTestCases", () => {
188196 } catch ( e ) { }
189197
190198 if ( testConfig . noTests ) return process . nextTick ( done ) ;
191- _require ( outputDirectory , "./bundle.js" ) ;
199+ _require ( outputDirectory , testConfig . bundlePath || "./bundle.js" ) ;
192200
193201 if ( exportedTests < 1 ) return done ( new Error ( "No tests exported by test case" ) ) ;
194202 runIdx ++ ;
0 commit comments