Heads Up! You're viewing the docs for v0.8, an old version of Karma. v6.4 is the newest.

Public Api

Most of the time, you will be using Karma directly from the command line.

You can, however, call Karma programmatically from your node module. This might be helpful when using Karma with Grunt for instance.

karma.server #

server.start(options, [callback=process.exit]) #

Equivalent of karma start.

var server = require('karma').server;
server.start({port: 9877}, function(exitCode) {
  console.log('Karma has exited with ' + exitCode);
  process.exit(exitCode);
});

karma.runner #

runner.run(options, [callback=process.exit]) #

Equivalent of karma run.

var runner = require('karma').runner;
runner.run({runnerPort: 9100}, function(exitCode) {
  console.log('Karma has exited with ' + exitCode);
  process.exit(exitCode);
});