Karma Log Level Values

karma-runnerunit testing

I use Karma as my test runner when running my unit tests and while looking at the Karma Configuration documentation, I noticed that there exists different levels of logging.

Currently, our code base uses: logLevel: config.LOG_INFO,

Is there a reason to use this one instead of the others?

Possible values:

  • config.LOG_DISABLE
  • config.LOG_ERROR
  • config.LOG_WARN
  • config.LOG_INFO
  • config.LOG_DEBUG

Also, anyone have an idea of what each log level does?

Best Answer

Is there a reason to use this one instead of the others?

Yes they each have varying levels of output. For example when trying to debug Karma errors that are difficult to track down and not being shown in the browser console or command window output (depending on where you have the configured results to display), you can change the following value in configuration which will yield more information output:

logLevel: config.LOG_DEBUG

This will give you a 'play by play' verbose detail of the Karma output.

Also, anyone have an idea of what each log level does?

The detailed documentation is sketchy at best and even the source on Github doesn't have great details. However the constants are somewhat self explanatory. Based on another property though, it dictates that these constants provide details in descending order (DEBUG being the most verbose, and DISABLE being the least/nothing):

LOG_DISABLE, LOG_ERROR, LOG_WARN, LOG_INFO, LOG_DEBUG

https://github.com/karma-runner/karma/blob/c5dc62db7642b8ca9504e71319e3b80143b8510a/docs/dev/04-public-api.md

Related Topic