UPDATE: tl;dr; I updated my npm packages and couldn't see any console.log
output anymore in karma. Looks like it's b/c of a behavior change that only shows console.log
output at the LOG_DEBUG
level and hides it at LOG_INFO
. When was that change made and is there a way to revert it?
ORIGINAL: When I run karma from a windows command prompt I cannot see the output of console.log
. I used to see it fine in many projects, but now it's suddenly not working in any of my projects. This seems to have changed after I ran npm update
in one project. I did not npm update
any other project, but they all stopped working.
I created an MCVE with a clean project and I still see the same behavior. Here's a list of the installed packages in my clean project (output from npm list
)
C:\...\mvce>npm list
[email protected] C:\...\mvce
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
`-- [email protected]
and here's the config code
karma.conf.js
module.exports = function(config) {
config.set({
autoWatch: false,
singleRun: true,
basePath: ".",
frameworks: ["jasmine"],
logLevel: "INFO",
browsers: ["PhantomJS", "Chrome"],
files: ["test.js"]
});
};
test.js
describe("describe", function(){
it("it", function(){
console.log("test");
});
});
Note I have already tried adding both of these to my karma.conf.js
. They make no difference.
client: {
captureConsole: true
}
// or
loggers: [
{ type: "console" }
]
NOTE: I've seen this issue on karma github, none of the suggestions there help. Also, it's describing a setup w/ mocha, I'm using jasmine - and the official workaround is to use captureConsole
which I tried.
I also created a gist for this issue.
Environment info:
- Windows 10 Home w/ all current updates
- Node v7.2.1
- Chrome 56
UPDATE: tl;dr; I updated my npm packages and couldn't see any console.log
output anymore in karma. Looks like it's b/c of a behavior change that only shows console.log
output at the LOG_DEBUG
level and hides it at LOG_INFO
. When was that change made and is there a way to revert it?
ORIGINAL: When I run karma from a windows command prompt I cannot see the output of console.log
. I used to see it fine in many projects, but now it's suddenly not working in any of my projects. This seems to have changed after I ran npm update
in one project. I did not npm update
any other project, but they all stopped working.
I created an MCVE with a clean project and I still see the same behavior. Here's a list of the installed packages in my clean project (output from npm list
)
C:\...\mvce>npm list
[email protected] C:\...\mvce
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
`-- [email protected]
and here's the config code
karma.conf.js
module.exports = function(config) {
config.set({
autoWatch: false,
singleRun: true,
basePath: ".",
frameworks: ["jasmine"],
logLevel: "INFO",
browsers: ["PhantomJS", "Chrome"],
files: ["test.js"]
});
};
test.js
describe("describe", function(){
it("it", function(){
console.log("test");
});
});
Note I have already tried adding both of these to my karma.conf.js
. They make no difference.
client: {
captureConsole: true
}
// or
loggers: [
{ type: "console" }
]
NOTE: I've seen this issue on karma github, none of the suggestions there help. Also, it's describing a setup w/ mocha, I'm using jasmine - and the official workaround is to use captureConsole
which I tried.
I also created a gist for this issue.
Environment info:
- Windows 10 Home w/ all current updates
- Node v7.2.1
- Chrome 56
1 Answer
Reset to default 34Looks like karma added a feature in v1.5.0 to filter console capture by log level. Here's a link to the git pull request and the code changes showing what happened. I couldn't find any updates in the docs about this new feature. Based on the code changes, here are the new rules
You can configure browserConsoleLogOptions
in your karma conf file to specify what messages should appear on your terminal output. Set the level
property to specify the maximum level that should be displayed. To display all messages, set level
to an empty string.
For my case, I needed to set it like this:
browserConsoleLogOptions: {
terminal: true,
level: ""
}
UPDATE: There's an open git issue discussing this. There are actually two changes in karma 1.5 that matter here.
- They changed the order of severity for log messages so that
LOG
==DEBUG
. The severity usedLOG
>INFO
. That means any project has log level set toINFO
would showconsole.log
messages in the old version and not show them in the new system. - As mentioned above they added support to filter console by log level with
browserConsoleLogOptions
.
it("it", function(done)
and thendone()
under the console.log – ssuperczynski Commented Feb 21, 2017 at 21:38