question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Messages written to console.log don't show up in the terminal

See original GitHub issue

Hi. I am using karma server to run my mocha unit tests for an angular app. The problem I am having is that messages that I write inside each it to console.log don’t show up in the terminal. They do show up, however, if I simply run mocha [unit_test_file_name].js at command line. Am I missing something in the configuration? Here are my files:

// gulfile.js
karma = require('karma').server,
gulp.task('unit', function (done) {
  karma.start({
    configFile: __dirname + '/config/unit/karma-unit.conf.js',
    singleRun: true
  }, done);
});
// karma-unit-conf
module.exports = function(config) {
  config.set({

    basePath: '../../',
    autoWatch: false,
    frameworks: ['mocha', 'chai', 'sinon-chai', 'chai-as-promised'],
    // frameworks: ['mocha'],
    browsers: ['PhantomJS'],

    files: [
      'bower_components/angular/angular.js',
      'bower_components/lodash/dist/lodash.js',
      'app/**/*.coffee'
    ],

    plugins: [
      'karma-chrome-launcher',
      'karma-firefox-launcher',
      'karma-phantomjs-launcher',
      'karma-script-launcher',
      'karma-mocha',
      'karma-chai-plugins',
      'karma-coffee-preprocessor'
    ],

    preprocessors: {
      '**/*.coffee': ['coffee']
    },

    coffeePreprocessor: {
      options: {
        bare: true,
        sourceMap: false
      },
      transformPath: function(path) {
        return path.replace(/\.coffee$/, '.js');
      }
    },

    logLevel: config.LOG_DEBUG,

    client: {
      mocha: {
        bail: true
      }
    }
  });
};

Thank you!

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:33 (5 by maintainers)

github_iconTop GitHub Comments

92reactions
maksimrcommented, Sep 7, 2014

@demisx hi!

Put captureConsole to property client in karma.conf.js:

    client: {
      captureConsole: true,
      mocha: {
        bail: true
      }
    }

This problem relate to Karma and we have issue. Thanks

66reactions
sdtsuicommented, Mar 17, 2017

As of v1.5.0, modifications on the client key do not solve this issue. For example: 👎

client: {
  captureConsole: true,
  mocha: {
    bail: true
  }
},

Modifying browserConsoleLogOptions: 👍 worked.

    browserConsoleLogOptions: {
      level: 'log',
      format: '%b %T: %m',
      terminal: true
    }

See issues: #2582 & #2228 for more info.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Console.log messages do not appear in VSCode terminal ...
log command appears. I've tried changing the default terminal for VSCode to cmd.exe instead of powershell but had the same results.
Read more >
Console app not showing info and debug logs
Using Terminal, with the command, all message types are visible in the Terminal output: -. sudo log stream --level debug. I've tried running...
Read more >
How do I disable messages or logging from printing on the ...
You can use the command sudo dmesg -n 1. to suppress all messages from the kernel (and its drivers) except panic messages from...
Read more >
JavaScript console.log() Method - W3Schools
The log() method writes (logs) a message to the console. The log() method is useful for testing purposes. Note. When testing console methods,...
Read more >
JavaScript Console.log() Example – How to Print to the ...
Just open the console, Ctrl+Shift+K or F12 , and in the top right you will see a button that says "Switch to multi-line...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found