diff --git a/spec/node-spec.js b/spec/node-spec.js index 678b8e9490f..886ad3d35bf 100644 --- a/spec/node-spec.js +++ b/spec/node-spec.js @@ -104,8 +104,16 @@ describe('node feature', function () { }) describe('child_process.spawn', function () { + let child + + afterEach(function () { + if (child != null) { + child.kill() + } + }) + it('supports spawning Electron as a node process via the ELECTRON_RUN_AS_NODE env var', function (done) { - const child = ChildProcess.spawn(process.execPath, [path.join(__dirname, 'fixtures', 'module', 'run-as-node.js')], { + child = ChildProcess.spawn(process.execPath, [path.join(__dirname, 'fixtures', 'module', 'run-as-node.js')], { env: { ELECTRON_RUN_AS_NODE: true } @@ -124,6 +132,27 @@ describe('node feature', function () { done() }) }) + + it('supports starting the v8 inspector with --inspect/--inspect-brk', function (done) { + child = ChildProcess.spawn(process.execPath, ['--inspect-brk', path.join(__dirname, 'fixtures', 'module', 'run-as-node.js')], { + env: { + ELECTRON_RUN_AS_NODE: true + } + }) + + let output = '' + child.stderr.on('data', function (data) { + output += data + + if (output.trim().startsWith('Debugger listening on port')) { + done() + } + }) + + child.stdout.on('data', function (data) { + done(new Error(`Unexpected output: ${data.toString()}`)) + }) + }) }) })