Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
12
rated 0 times [  19] [ 7]  / answers: 1 / hits: 130289  / 12 Years ago, sat, may 19, 2012, 12:00:00

I am using the javascript test-runner Mocha.



I have a test that is failing, so I would to debug it using console.log.



But when the tests are run, there is no output (only the test results from Mocha).
It seems like Mocha has captured and suppressed my console.log output!



How can I get Mocha to show my output? (at for tests that fail)?



EDIT:



Huge apologies! — console.log does work during tests! I must have been expecting it to suppress the output, and I didn't properly check my own code. Thanks for responding.
So... that being said... maybe it actually would be nice to suppress the output for tests that pass? hmm...



On a related note: I want to use console.log because I am having a lot of trouble trying to get the Eclipse debugger to connect to node.js.



Am I the only one who finds this tricky? How do you guys debug node.js? With a debugger, or with console.log statements?


More From » node.js

 Answers
8

What Mocha options are you using?



Maybe it is something to do with reporter (-R) or ui (-ui) being used?



console.log(msg);


works fine during my test runs, though sometimes mixed in a little goofy. Presumably due to the async nature of the test run.



Here are the options (mocha.opts) I'm using:



--require should
-R spec
--ui bdd


Hmm..just tested without any mocha.opts and console.log still works.


[#85477] Friday, May 18, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
luna

Total Points: 698
Total Questions: 114
Total Answers: 93

Location: Israel
Member since Wed, Apr 14, 2021
3 Years ago
luna questions
;