Bruno Siqueira
Bruno Siqueira

Reputation: 892

Karma Testing in Gulp: TypeError: undefined is not a function

I am following gulp-karma github page to make 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 package.json:

"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 karma tests via command line, it works fine (some tests passing, some not), but when I run 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 anybody have any idea of what am I doing wrong?

Upvotes: 3

Views: 2655

Answers (2)

Liran Brimer
Liran Brimer

Reputation: 3556

npm uninstall gulp-karma

that fixed it for me

Upvotes: 0

Bruno Siqueira
Bruno Siqueira

Reputation: 892

In the end, I had to update to a newer version, not only karma libraries, but also Gulp (updated Gulp from 3.8.1 to 3.9.0, since updating only karma was generating another error).

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",

Upvotes: 2

Related Questions