4

I have a dependency with Intern where we have to spin up a Selenium server and use PhantomJS for our tests. We use Jenkins and may need some more inspection/debug output to console but the console.log's get suppressed from the test files to terminal/command-line

Is console.log to terminal/command-line supported yet?

d48
  • 702
  • 7
  • 15
  • Would the purpose be to return back stdout to the Jenkins console output? – Anthony Forloney Dec 17 '14 at 00:53
  • yes and also for local development debugging specific to stdout – d48 Dec 17 '14 at 00:54
  • When I ran into a similar scenario, I had resorted to writing my logs into a file that was accessible by the Jenkins instance; to which I added an extra build step to read the contents of the file so they are readable from within Jenkins. Not a completely ideal and foolproof plan, but it got the job done. – Anthony Forloney Dec 17 '14 at 00:56
  • thanks for the info. How did you using console.log() from your javascript file to a file where the runner resides? – d48 Dec 17 '14 at 22:16

1 Answers1

4

How console.log works with intern-runner depends on where your test code is running. Unit tests (specified with suites) run in the browser, so that's where console.log output ends up. There isn't currently a way to get console output out of a browser for unit tests.

Functional tests (specified with functionalSuites) control a browser, but actually run in Node.js, so output from console.log statements in functional tests generally goes to intern's stdout. The exceptions are log statements in execute and executeAsync blocks; since those blocks run in the browser, that's where the log output ends up. You can retrieve browser logs in functional tests using getLogsFor('browser'), but WebDriver log support is inconsistent between browsers.

jason0x43
  • 3,363
  • 1
  • 16
  • 15
  • thanks for the reply @jason0x43. We have a dependency to run our unit tests in a browser context but still need to potentially debug or have more detailed console.logs at the command-line for our CI environment. Since we use phantomjs as a browser configuration, would I be able to use that `getLogsFor('browser')` in the same way to get the output I'm looking for? – d48 Dec 18 '14 at 17:23
  • Documentation of the getLogsFor() method: https://theintern.github.io/leadfoot/module-leadfoot_Command.html#getLogsFor – Kiechlus Jun 15 '16 at 09:35