karma-background

0.1.0 • Public • Published

karma-background

Why?

When using karma within gulp, if you want to programmatically call the karma runner while a server is already started, it ouputs all the logs twice. In grunt-karma they got around this by spawning the karma server as a background process.

This module is not a gulp plugin, all it does is spawn karma in a background process in the same fashion as the grunt-karma plugin.

example

Since I wrote this specifically to be used with gulp, the following example is a gulpfile! You can also look at the gulpfile within this directory.

var gulp = require('gulp');
var karma = require('karma');
var kbg = require('karma-background');
var configFile = __dirname + '/karma.conf.js';
 
// do a single run per usual
gulp.task('karma', function (done) {
  new karma.Server({
    configFile: karmaPath,
    singleRun: true
  }, done).start();
});
 
// call the runner
gulp.task('karma:run', function (done) {
  karma.runner.run({
    configFile: configFile
  }, done);
});
 
// create a watch task that launches a background process
gulp.task('watch', function () {
  kbg({ configFile: configFile });
  gulp.watch('./**.js', ['karma:run']);
});

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i karma-background

Weekly Downloads

1

Version

0.1.0

License

MIT

Last publish

Collaborators

  • callmehiphop