November 14, 2015

The other day I could not find an acceptable Karma task for Gulp, so I spent some time on my own. Using Karma ~1.3.0 and Gulp ~3.9.0.

{% gist bendangelo/8c83911268902bf85f0c %}

process.exit will stop the task, preventing weird error messages from Gulp. I think Karma calls the complete method for each test file? I don’t know, either way it makes the two dance well together.

One more thing, just a warning do not refactor the last task to match.

var karmaServer = new karma.Server({
    configFile: __dirname + '/test/karma.conf.js'
}, done).start();

There is an integration problem where Gulp will try to read the arguments sent into the done() method. More about this pestering issue here.