According to this post (and the general internet) if I want to run a Karma test without these kinds of code coverage commands...
__cov_9C0014nbzu2SxN3FICah6Q.f['35']++;
__cov_9C0014nbzu2SxN3FICah6Q.s['138']++;
...I simply need to set the --debug
option in the terminal like so:
$ karma start karma.conf.js --browsers=Chrome --single-run=false --debug
However, when running your Karma tests via a Gulp task the documentation seems to be missing. I'm using a simply karma.start
config object below. I've tried setting the debug
property to either true
or the strign '--debug'
, however neither seems to have an effect (although the tests do run/the runner doesn't crash).
karma.start({
configFile: __dirname + '/karma.conf.js',
exclude: excludeFiles,
singleRun: !!singleRun,
debug: '--debug'
}, karmaCompleted);
Any ideas how to set the debug option when running your Karma tests from a Gulp task?
Setting debug: true
in the options object I pass to karma.start
works just as well as using --debug
at the command line. In other words, what you said you did in your Gulpfile works to get the debug
option to Karma. However,
I simply need to set the
--debug
option in the terminal like so
No, the page you link to shows that you also need to customize your configuration to tweak the preprocessor list so that when --debug
is used the list is empty. The problem you have is consistent with having failed to perform that customization correctly.
Here is how the customization could be performed. This queries the value of config.debug
from the configuration that Karma has already parsed from the command line:
module.exports = function configure(config) {
config.set({
// ...
preprocessors: {
"index.js": config.debug ? [] : ["coverage"],
},
// ...
});
};
Scanning process.argv
for --debug
like suggested on the page you took the idea from won't work when you invoke Karma from Gulp because the debug
option is passed directly through the configuration. Inspecting config.debug
works both at the command line and when Karma is invoked through it's programmatic API.