Override console.log/error/warn in headless mode to log to stdout/stderr

This commit is contained in:
Nathan Sobo
2015-10-17 10:55:23 -06:00
parent c35411cd29
commit 979b08f5fe

View File

@@ -15,9 +15,19 @@ try
{testRunnerPath, legacyTestRunnerPath, headless, logFile, testPaths} = getWindowLoadSettings()
# Show window synchronously so a focusout doesn't fire on input elements
# that are focused in the very first spec run.
remote.getCurrentWindow().show() unless headless
if headless
# Override logging in headless mode so it goes to the console, regardless
# of the --enable-logging flag to Electron.
console.log = (args...) ->
ipc.send 'write-to-stdout', args.join(' ') + '\n'
console.warn = (args...) ->
ipc.send 'write-to-stderr', args.join(' ') + '\n'
console.error = (args...) ->
ipc.send 'write-to-stderr', args.join(' ') + '\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()
handleKeydown = (event) ->
# Reload: cmd-r / ctrl-r