Skip to content
This repository was archived by the owner on Jul 29, 2024. It is now read-only.

Commit d1266da

Browse files
committed
chore(runner): wait for debugger using then block (#4014)
Closes #3898
1 parent 60d9114 commit d1266da

File tree

1 file changed

+20
-13
lines changed

1 file changed

+20
-13
lines changed

lib/runner.ts

+20-13
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export class Runner extends EventEmitter {
3636
plugins_: Plugins;
3737
restartPromise: q.Promise<any>;
3838
frameworkUsesAfterEach: boolean;
39+
ready_?: wdpromise.Promise<void>;
3940

4041
constructor(config: Config) {
4142
super();
@@ -49,16 +50,18 @@ export class Runner extends EventEmitter {
4950
process['_debugProcess'](process.pid);
5051
let flow = wdpromise.controlFlow();
5152

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+
});
6265
}
6366

6467
if (config.capabilities && config.capabilities.seleniumAddress) {
@@ -304,9 +307,13 @@ export class Runner extends EventEmitter {
304307
throw new Error('Spec patterns did not match any files.');
305308
}
306309

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+
})
310317
.then(() => {
311318
// 2) Create a browser and setup globals
312319
browser_ = this.createBrowser(plugins);

0 commit comments

Comments
 (0)