@@ -36,6 +36,7 @@ export class Runner extends EventEmitter {
36
36
plugins_ : Plugins ;
37
37
restartPromise : q . Promise < any > ;
38
38
frameworkUsesAfterEach : boolean ;
39
+ ready_ ?: wdpromise . Promise < void > ;
39
40
40
41
constructor ( config : Config ) {
41
42
super ( ) ;
@@ -49,16 +50,18 @@ export class Runner extends EventEmitter {
49
50
process [ '_debugProcess' ] ( process . pid ) ;
50
51
let flow = wdpromise . controlFlow ( ) ;
51
52
52
- flow . execute ( ( ) => {
53
- let nodedebug = require ( 'child_process' ) . fork ( 'debug' , [ 'localhost:5858' ] ) ;
54
- process . on ( 'exit' , function ( ) {
55
- nodedebug . kill ( 'SIGTERM' ) ;
56
- } ) ;
57
- nodedebug . on ( 'exit' , function ( ) {
58
- process . exit ( 1 ) ;
59
- } ) ;
60
- } , 'start the node debugger' ) ;
61
- flow . timeout ( 1000 , 'waiting for debugger to attach' ) ;
53
+ this . ready_ = flow . execute ( ( ) => {
54
+ let nodedebug =
55
+ require ( 'child_process' ) . fork ( 'debug' , [ 'localhost:5858' ] ) ;
56
+ process . on ( 'exit' , function ( ) {
57
+ nodedebug . kill ( 'SIGTERM' ) ;
58
+ } ) ;
59
+ nodedebug . on ( 'exit' , function ( ) {
60
+ process . exit ( 1 ) ;
61
+ } ) ;
62
+ } , 'start the node debugger' ) . then ( ( ) => {
63
+ return flow . timeout ( 1000 , 'waiting for debugger to attach' ) ;
64
+ } ) ;
62
65
}
63
66
64
67
if ( config . capabilities && config . capabilities . seleniumAddress ) {
@@ -304,9 +307,13 @@ export class Runner extends EventEmitter {
304
307
throw new Error ( 'Spec patterns did not match any files.' ) ;
305
308
}
306
309
307
- // 1) Setup environment
308
- // noinspection JSValidateTypes
309
- return this . driverprovider_ . setupEnv ( )
310
+ // 0) Wait for debugger
311
+ return q ( this . ready_ )
312
+ . then ( ( ) => {
313
+ // 1) Setup environment
314
+ // noinspection JSValidateTypes
315
+ return this . driverprovider_ . setupEnv ( ) ;
316
+ } )
310
317
. then ( ( ) => {
311
318
// 2) Create a browser and setup globals
312
319
browser_ = this . createBrowser ( plugins ) ;
0 commit comments