Merge pull request #18863 from atom/aw/console-in-tests

Allow the use of console, stdout, and stderr in Jasmine tests
This commit is contained in:
Ash Wilson 2019-02-17 18:36:02 -05:00 committed by GitHub
commit 1acf91383c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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()