21

I'm using mocha along with yeiwd and chai to test a javascript web application. I'd like to see console logs from within the application to help debug some tests.

When I run the tests from the comand line with npm test I don't see any console.log() output, only mocha output.

Is there a way to view logs created from within the application code?

Update - here is my package.json

{
  "devDependencies": {
    "chai": "^2.3.0",
    "chai-colors": "^1.0.0",
    "yiewd": "^0.6.0"
  },
  "scripts": {
    "test": "mocha --harmony --timeout 0 tests/*/*.js"
  }
}
12
  • Hm I don't use npm test often but just tried it and had no problem having my console.log print during the test. What happens when you run a mocha test directly? By running mocha testName.js from the command? Do you see anything there? Commented Sep 28, 2015 at 15:32
  • 3
    I can use console.log within my tests but not from within the application code Commented Sep 28, 2015 at 15:36
  • Yes console.log works within the application code for me, and it is indeed supposed to. Are you using any special command line arguments? See this thread stackoverflow.com/questions/10666349/… Commented Sep 28, 2015 at 15:41
  • 1
    I can confirm that running your exact parameters in my test still shows the console.logs from within my application code on the terminal right there alongside my mocha logs. The only difference is I'm not running yiewd but I don't see how that would affect anything. Either way console.log is supposed to work in a mocha test by default, so there must be something stopping it in your environment somewhere. Commented Sep 28, 2015 at 15:49
  • 15
    Wish this had been answered Commented Mar 19, 2017 at 17:46

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.