From f0fb2888493de9320c883a2c57536d5500f80001 Mon Sep 17 00:00:00 2001 From: Ash Wilson Date: Sun, 17 Feb 2019 14:18:33 -0500 Subject: [PATCH] Override console.(log|error) and process.std(out|err) when headless --- src/initialize-test-window.coffee | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/initialize-test-window.coffee b/src/initialize-test-window.coffee index 4cbd02bfd..e80fc86a6 100644 --- a/src/initialize-test-window.coffee +++ b/src/initialize-test-window.coffee @@ -32,7 +32,17 @@ module.exports = ({blobStore}) -> {testRunnerPath, legacyTestRunnerPath, headless, logFile, testPaths, env} = getWindowLoadSettings() - unless headless + if headless + # Install console functions that output to stdout and stderr. + util = require 'util' + + Object.defineProperties process, + stdout: {value: remote.process.stdout} + stderr: {value: remote.process.stderr} + + console.log = (args...) -> process.stdout.write "#{util.format(args...)}\n" + console.error = (args...) -> process.stderr.write "#{util.format(args...)}\n" + else # Show window synchronously so a focusout doesn't fire on input elements # that are focused in the very first spec run. remote.getCurrentWindow().show()