node-karma-wrapper

Karma test runner wrapper


Keywords
gulpfriendly, helper, karma, test, unit, runner, TDD
License
MIT
Install
npm install node-karma-wrapper@0.3.0

Documentation

node-karma-wrapper Build Status NPM version

I'm just wrapping the the karma public API here.

Information

Package node-karma-wrapper
Description Karma test runner helper
Node Version >= 0.8

Usage

var karma = require('node-karma-wrapper');

// Preconfig you server
var aKarmaTestServer = karma({ configFile : './test/karma.conf.js');

// Then run once
aKarmaTestServer.simpleRun();

// Run in background
aKarmaTestServer.inBackground();

// Normal launch
aKarmaTestServer.start();

// Run the tests using the already started karma server
aKarmaTestServer.run();

Api

karma(configs)

Defines a karma server with a specific configuration (see the official api). Return a « Karma Helper Object »

« Karma Helper Object » methods

kho.start([callback])

Equivalent of karma start.

kho.run(callback)

Equivalent of karma run.

kho.inBackground([callback])

On continuous integration you can start the karma server without blocking the main process and without logging anything.

kho.simpleRun([callback])

Equivalent of karma start with the singleRun option on.

Travis CI trick

Here is a way to run specific config on Travis :

var assign = require('lodash.assign');

// TRAVIS TRICKS
function testConfig(configFile, customOptions){
  var options = { configFile: configFile };
  var travisOptions = process.env.TRAVIS && { browsers: [ 'Firefox', 'PhantomJS'], reporters: ['dots'] };
  return assign(options, customOptions, travisOptions);
}