I expect to be able to console.log() on any spec.
Logs are printed only within the "describe" scope, but not within blocks beforeEach, it, etc.
Instead, a TypeError is returned "undefined is not a constructor (evaluating 'console.log()'...)"
describe('Some spec', function() {
console.log('it works!') // is logged
it('Should do something', function () {
console.log('it does NOT work') // Type error. No logs. Spec is stopped (error thrown)
})
})
karma --version): 1.5.0karma.config.js file{
basePath: '',
frameworks: ['jasmine'],
exclude: [],
files: ['test_files.js'],
preprocessors: {
'./test_files.js': ['webpack']
},
reporters: ['spec', 'junit'],
junitReporter: {
outputDir: './results'
},
browserConsoleLogOptions: {
level: 'log',
format: '%b %T: %m',
terminal: true
},
webpack: require('./webpack_config.js'),
specReporter: {
suppressPassed: true, // do not print information about passed tests
suppressSkipped: false, // do not print information about skipped tests
},
port: 9876,
colors: true,
browsers: ['PhantomJS'],
plugins: [
require('karma-jasmine'),
require('karma-webpack'),
require('karma-junit-reporter'),
require('karma-spec-reporter'),
require('karma-sourcemap-loader'),
require('karma-chrome-launcher'),
require('karma-phantomjs-launcher')
]
}
@madroneropaulo this
console.log('it doesn't work :( ')
is invalid javascript.
Try this in your test:
console.log('foo');
@maksimr Ok that was a random text comment, I have valid text on my specs. Please reopen. I updated the issue. I don't want to create a new one.
@madroneropaulo can you create a stub project which reproduces this error?
Because I see nothing strange in your config.
Thanks
@madroneropaulo see https://github.com/karma-runner/karma/issues/2582
Looks like you are missing two things in your config: client.captureConsole = true and logLevel: config.LOG_LOG,. As @wbruno says, take a look at #2582 very carefully.
@wbruno and @leegee are correct, your issue should be solved by implementing the config changes described in the last comment on #2582.
Most helpful comment
@madroneropaulo see https://github.com/karma-runner/karma/issues/2582