diff --git a/lib/tests/test.js b/lib/tests/test.js index 8c61b15a..f83f276e 100644 --- a/lib/tests/test.js +++ b/lib/tests/test.js @@ -144,26 +144,28 @@ class Test { self.engine.startService("codeCoverage"); if (self.options.node === 'embark') { - return self.engine.ipc.connect((err) => { - if (err) { - this.engine.logger.error(err.message || err); - this.engine.logger.error("Could not connect to Embark's IPC. Is embark running?"); - process.exit(1); - } - self.engine.ipc.request('blockchain:node', {}, (err, node) => { - if (err) { - return self.engine.logger.error(err.message || err); - } - self.options.node = node; - cb(); - }); - }); + if (!self.engine.ipc.connected) { + self.engine.logger.error("Could not connect to Embark's IPC. Is embark running?"); + process.exit(1); + } + return self.connectToIpcNode(cb); } cb(); } ], callback); } + connectToIpcNode(cb) { + this.engine.ipc.request('blockchain:node', {}, (err, node) => { + if (err) { + this.engine.logger.error(err.message || err); + return cb(); + } + this.options.node = node; + cb(); + }); + } + onReady(callback) { const self = this; if (this.ready) {