Running your Karma tests

Next, we want to run our tests. Of course, we already created some tests and ran them with Karma. No worries, we are not going to undo all that. Instead, we are going to run Karma automatically using Gulp. That way, we lint, test, and minify our code with a single gulp command. There used to be a Karma plugin for Gulp, but now it is recommended to just run Karma directly from Gulp. This is actually surprisingly easy:

var gulp = require('gulp');var karma = require('karma').Server;gulp.task('test', function () {   new karma({      configFile: __dirname + '/test/karma.conf.js'   }).start();});

The __dirname variable is a global Node.js variable and contains the current file path. So, we set up a new Karma server from code, pass ...

Get Continuous Integration, Delivery, and Deployment now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.