Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V1.0.0 does NOT console.log() to the terminal, only logs in the browser's console #2187

Closed
shardool opened this issue Jun 24, 2016 · 7 comments · May be fixed by Omrisnyk/npm-lockfiles#122 or Omrisnyk/npm-lockfiles#132

Comments

@shardool
Copy link

shardool commented Jun 24, 2016

Expected behavior :

console.log('hello world') should log to the terminal when used with the karma-phantomjs-launcher. The previous version V - 0.13.22 logs to the terminal fine

Actual behavior:

does NOT console.log() to the terminal. logs only to the browser's console (chrome's console when karma-chrome-launcher is used)

Enviroment Details

  • Karma version (output of karma --version): V 1.0.0
  • Relevant part of your karma.config.js file

Steps to reproduce the behaviour

1.Karma with Jasmine
2.Chrome and PhatomJS as the browsers
3.Console Logs fine in Chrome, but NOT in the terminal, the previous version of Karma V 0.13.22 works fine
4. And oh !... I'm using Mac

@shardool shardool changed the title V1.0.0 does NOT Console.log() to the terminal, only logs in the browser's console V1.0.0 does NOT console.log() to the terminal, only logs in the browser's console Jun 24, 2016
@shardool
Copy link
Author

thank you very much @dignifiedquire

@dignifiedquire
Copy link
Member

You are welcome :) Release should go out in the next hours

@leoselig
Copy link

leoselig commented Jun 28, 2016

I'm still having this issue on v1.1.0 using karma-phantomjs-launcher
This is my karma.config.js

module.exports = function(config) {
  config.set({

    logLevel: config.LOG_DEBUG,

    // base path that will be used to resolve all patterns (eg. files, exclude)
    basePath: '../',


    // frameworks to use
    // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
    frameworks: ['mocha'],

    files: [
         // only specify one entry point
         // and require all tests in there
         'test/index.js'
     ],

     // list of files to exclude
     exclude: [
     ],

     preprocessors: {
         // add webpack as preprocessor
         'test/index.js': ['webpack']
     },


    // test results reporter to use
    // possible values: 'dots', 'progress'
    // available reporters: https://npmjs.org/browse/keyword/karma-reporter
    reporters: ['mocha'],


    // web server port
    port: 9876,


    // enable / disable colors in the output (reporters and logs)
    colors: true,


    // level of logging
    // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
    logLevel: config.LOG_INFO,


    // enable / disable watching file and executing tests whenever any file changes
    autoWatch: false,


    // start these browsers
    // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
    browsers: ['PhantomJS'],


    // Continuous Integration mode
    // if true, Karma captures browsers, runs the tests and exits
    singleRun: true,

    // Concurrency level
    // how many browser should be started simultaneous
    concurrency: Infinity,

    webpack: karmaWebpackConfig,

    webpackMiddleware: {
        // webpack-dev-middleware configuration
        // i. e.
        noInfo: true
    },

    client: {
      captureConsole: true
    }

  });
};

@dignifiedquire
Copy link
Member

@leoselig can you try with a different browser?

@leoselig
Copy link

@dignifiedquire I just tried with Chrome, same behavior

Details:
I have a console.log(...) at the beginning of my spec

I ran:

@shardool
Copy link
Author

It works for me though. I just tried [email protected] and it console logs both, to the terminal and the browser's console. Here is my karma.conf.js. (You may have to explicitly add the launchers to the plugins:[ ] array in the karma.conf file)

// Karma configuration
// Generated on Tue Jun 28 2016 23:13:27 GMT-0700 (PDT)
'use strict';
module.exports = function(config) {
    var path = require('path');
    config.set({

    // base path that will be used to resolve all patterns (eg. files, exclude)
    basePath: './',


    // frameworks to use
    // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
    frameworks: ['jasmine'],


    // list of files / patterns to load in the browser
    files: [
    'specLoader.js',
    'node_modules/sinon/pkg/sinon.js'
    ],


    // list of files to exclude
    exclude: [
    ],


    // preprocess matching files before serving them to the browser
    // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
    preprocessors: {
        'specLoader.js':['webpack']
    },


    // test results reporter to use
    // possible values: 'dots', 'progress'
    // available reporters: https://npmjs.org/browse/keyword/karma-reporter
    reporters: ['progress','coverage'],


    // web server port
    port: 9876,


    // enable / disable colors in the output (reporters and logs)
    colors: true,


    // level of logging
    // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
    logLevel: config.LOG_INFO,


    // enable / disable watching file and executing tests whenever any file changes
    autoWatch: true,


    // start these browsers
    // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
    browsers: ['Chrome', 'PhantomJS'],


    // Continuous Integration mode
    // if true, Karma captures browsers, runs the tests and exits
    singleRun: false,

    // Concurrency level
    // how many browser should be started simultaneous
    concurrency: Infinity,
    plugins:[
    require('karma-webpack'),
    require('karma-jasmine'),
    require('karma-chrome-launcher'),
    require('karma-phantomjs-launcher'),
    require('karma-coverage')
    ],
    webpack:{
        module:{
            preLoaders:[{
                test:/\.js$/,
                include:path.resolve('sut'),
                loader:'istanbul-instrumenter-loader'
            }]
        }
    }
});
};

@4kochi
Copy link
Contributor

4kochi commented Jun 30, 2016

Should be resolved by #2220

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants