Trying to run karma using gulp for running tests but after following the example from: 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 I run: gulp test I get the Error:
TypeError: Server is not a function at Gulp.<anonymous>
Any suggestions of what might be wrong?
Which version of karma do you have installed?
The API has changed from 0.12
to 0.13
and the example you've shown is the one for 0.13
.
The previous API was the following:
var server = require('karma').server;
//... more code
server.start( { .... } , function(exitCode){
// ...
});
The issue was that karma-cli npm module wasn't properly installed globally. Running: npm install -g karma-cli
solved the issue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With