Garmp test karma TypeError: server is not a function

Trying to start karma with gulp to run tests, but after running the example: https://github.com/karma-runner/gulp-karma

My gulp file:

var gulp = require('gulp'); var Server = require('karma').Server; /** * Run test once and exit */ gulp.task('test', function (done) { new Server({ configFile: __dirname + '/karma.conf.js', singleRun: true }, done).start(); }); /** * Watch for file changes and re-run tests on each change */ gulp.task('tdd', function (done) { new Server({ configFile: __dirname + '/karma.conf.js' }, done).start(); }); gulp.task('default', ['tdd']); 

after starting: gulp test I get an error message:

 TypeError: Server is not a function at Gulp.<anonymous> 

Any suggestions on what might be wrong?

+8
javascript angularjs testing gulp karma-runner
source share
2 answers

The problem was that the karma-cli npm module was not installed correctly globally. Launch: npm install -g karma-cli solved the problem.

+2
source share

What version of karma have you installed?

The API has changed from 0.12 to 0.13 and the example you showed is a unit for 0.13 .

The previous API was as follows:

 var server = require('karma').server; //... more code server.start( { .... } , function(exitCode){ // ... }); 
+10
source share

All Articles