Skip to content

console.* functions called outside tests are not output when singleRun is false #3131

@tbhartman

Description

@tbhartman

Expected behaviour

Using client.captureConsole = true, I expect all console.* calls to output to the terminal.

d:\karma_captureConsole_bug> karma start
Chrome 68.0.3440 (Windows 10 0.0.0) INFO: 'I am outside of test!'

LOG: 'I am inside of test!'
Chrome 68.0.3440 (Windows 10 0.0.0): Executed 1 of 1 SUCCESS (0.007 secs / 0.001 secs)
TOTAL: 1 SUCCESS

Actual behaviour

Only console.* calls occurring while running a test are output to the terminal

d:\karma_captureConsole_bug> karma start
LOG: 'I am inside of test!'
Chrome 68.0.3440 (Windows 10 0.0.0): Executed 1 of 1 SUCCESS (0.007 secs / 0.001 secs)
TOTAL: 1 SUCCESS

Environment Details

  • Karma version (output of karma --version): 3.0.0

karma.conf.js:

module.exports = (config) => {
  config.set({
    client: {captureConsole: true},
    frameworks: ['jasmine', 'requirejs'],
    files: ['karma.test.js', 'script.js'],
    browsers: ['Chrome'],
    singleRun: false,
  })
};

karma.test.js:

require.config({
  deps: ['script'],
  callback: window.__karma__.start
});

script.js:

define('script', [], function(){
  console.info('I am outside of test!');
  it('test1', function(){
    console.log('I am inside of test!');
  });
});

Steps to reproduce the behaviour

  1. put above karma.conf.js, karma.test.js, script.js in a directory
  2. run karma start to see actual behavior
  3. change karma.conf.js so that singleRun is true to observe expected behavior

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions