diff --git a/spec/api-app-spec.js b/spec/api-app-spec.js index 035520bb414..58925deca48 100644 --- a/spec/api-app-spec.js +++ b/spec/api-app-spec.js @@ -162,19 +162,18 @@ describe('app module', function () { this.timeout(120000) const appPath = path.join(__dirname, 'fixtures', 'api', 'singleton') // First launch should exit with 0. - let secondLaunched = false const first = ChildProcess.spawn(remote.process.execPath, [appPath]) first.once('exit', (code) => { - assert.ok(secondLaunched) assert.equal(code, 0) - done() }) - // Second launch should exit with 1. - const second = ChildProcess.spawn(remote.process.execPath, [appPath]) - second.once('exit', (code) => { - assert.ok(!secondLaunched) - assert.equal(code, 1) - secondLaunched = true + // Start second app when received output. + first.stdout.once('data', () => { + // Second launch should exit with 1. + const second = ChildProcess.spawn(remote.process.execPath, [appPath]) + second.once('exit', (code) => { + assert.equal(code, 1) + done() + }) }) }) }) diff --git a/spec/fixtures/api/singleton/main.js b/spec/fixtures/api/singleton/main.js index 1cf75c4a664..07176e0097e 100644 --- a/spec/fixtures/api/singleton/main.js +++ b/spec/fixtures/api/singleton/main.js @@ -1,8 +1,6 @@ const {app} = require('electron') -process.on('uncaughtException', () => { - app.exit(2) -}) +console.log('started') // ping parent const shouldExit = app.makeSingleInstance(() => { process.nextTick(() => app.exit(0))