Karma Testing in Gulp: TypeError: undefined is not a function
I am following the gulp-karma github so that my karma tests run in travis-ci.
This is part of my Gulp file:
var gulp = require('gulp');
var Server = require('karma').server;
gulp.task('test', function (done) {
Server.start({
configFile: configFile,
singleRun: true
}, done);
});
and this is part of my .json package:
"karma": "0.12.0",
"karma-html2js-preprocessor": "0.1.0",
"karma-jade-preprocessor": "0.0.11",
"karma-jasmine": "0.1.5",
"karma-ng-html2js-preprocessor": "0.1.2",
"karma-phantomjs-launcher": "0.1.4",
"karma-requirejs": "0.2.1",
"karma-script-launcher": "0.1.0",
"karma-coffee-preprocessor": "0.2.1",
"brfs": "^1.2.0",
"browserify-shim": "~3.8.0",
"karma-browserify": "^3.0.0",
When I run the karma tests via the command line, it works fine (some tests pass and some don't), but when I run the Gulp test, I get the following error:
[22:11:19] Error: 1
at formatError (test-app/node_modules/gulp/bin/gulp.js:169:10)
at Gulp.<anonymous> (test-app/node_modules/gulp/bin/gulp.js:195:15)
at Gulp.emit (events.js:95:17)
at Gulp.Orchestrator._emitTaskDone (test-app/node_modules/gulp/node_modules/orchestrator/index.js:264:8)
at test-app/node_modules/gulp/node_modules/orchestrator/index.js:275:23
at finish (test-app/node_modules/gulp/node_modules/orchestrator/lib/runTask.js:21:8)
at cb (test-app/node_modules/gulp/node_modules/orchestrator/lib/runTask.js:29:3)
at Server.<anonymous> (test-app/node_modules/karma/lib/server.js:206:9)
at Server.g (events.js:180:16)
at Server.emit (events.js:117:20)
at net.js:1277:10
at process._tickCallback (node.js:448:13)
Does anyone have any idea what I am doing wrong?
+3
source to share
2 answers
In the end, I had to update to a newer version, not just the karma library, but also Gulp (updated Gulp from 3.8.1 to 3.9.0 as updating only karma generated another bug).
With this configuration, it started working again:
"gulp": "~3.9.0",
"karma": "~0.13.3",
"karma-browserify": "^3.0.0",
"karma-coffee-preprocessor": "~0.3.0",
"karma-html2js-preprocessor": "~0.1.0",
"karma-jade-preprocessor": "0.0.11",
"karma-jasmine": "^0.3.6",
"karma-ng-html2js-preprocessor": "^0.1.2",
"karma-phantomjs-launcher": "~0.2.0",
"karma-requirejs": "~0.2.2",
"karma-script-launcher": "~0.1.0",
"karma-spec-reporter": "0.0.20",
"brfs": "^1.2.0",
"browserify-shim": "~3.8.0",
"karma-browserify": "^3.0.0",
+2
source to share