From e899050500800357684d06b69d67e15074c452d9 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 12 Oct 2016 13:01:43 -0700 Subject: [PATCH] Add basic test of spawned ELECTRON_RUN_AS_NODE process --- spec/fixtures/module/run-as-node.js | 5 +++++ spec/node-spec.js | 23 +++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 spec/fixtures/module/run-as-node.js diff --git a/spec/fixtures/module/run-as-node.js b/spec/fixtures/module/run-as-node.js new file mode 100644 index 000000000..20812f046 --- /dev/null +++ b/spec/fixtures/module/run-as-node.js @@ -0,0 +1,5 @@ +console.log(JSON.stringify({ + processLog: typeof process.log, + processType: typeof process.type, + window: typeof window +})) diff --git a/spec/node-spec.js b/spec/node-spec.js index 5742bea7f..d6151175d 100644 --- a/spec/node-spec.js +++ b/spec/node-spec.js @@ -92,6 +92,29 @@ describe('node feature', function () { }) }) }) + + describe('child_process.spawn', function () { + 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')], { + env: { + ELECTRON_RUN_AS_NODE: true + } + }) + + let output = '' + child.stdout.on('data', function (data) { + output += data + }) + child.stdout.on('close', function () { + assert.deepEqual(JSON.parse(output), { + processLog: process.platform === 'win32' ? 'function' : 'undefined', + processType: 'undefined', + window: 'undefined' + }) + done() + }) + }) + }) }) describe('contexts', function () {