Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Karma Log Level Values

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?

like image 497
User 5842 Avatar asked Jun 20 '18 22:06

User 5842


People also ask

What is single run in karma?

The property singleRun controls how Karma executes, if set to true , Karma will start, launch configured browsers, run tests and then exit with a code of either 0 or 1 depending on whether or not all tests passed.

What is karma config file?

The Karma configuration file can be written in JavaScript, CoffeeScript, or TypeScript and is loaded as a regular Node. js module. Unless provided as argument, the Karma CLI will look for a configuration file at. ./karma.conf.js.

Does karma run tests in parallel?

Karma-parallelThis npm package splits your unit tests into multiple suites that run in parallel with each other, on different threads of your processor.


1 Answers

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

like image 81
atconway Avatar answered Sep 18 '22 08:09

atconway