Timur Timur - 1 year ago 124
Node.js Question

Issue running karma task from gulp

I am trying to run karma tests from gulp task and I am getting this error:

Error: 1
at formatError (C:\Users\Tim\AppData\Roaming\npm\node_modules\gulp\bin\gulp.js:161:10)
at Gulp.<anonymous> (C:\Users\Tim\AppData\Roaming\npm\node_modules\gulp\bin\gulp.js:187:15)
at Gulp.emit (events.js:95:17)
at Gulp.Orchestrator._emitTaskDone (C:\path\to\project\node_modules\gulp\node_modules\orchestrator\index.js:264:8)
at C:\path\to\project\node_modules\gulp\node_modules\orchestrator\index.js:275:23
at finish (C:\path\to\project\node_modules\gulp\node_modules\orchestrator\lib\runTask.js:21:8)
at cb (C:\path\to\project\node_modules\gulp\node_modules\orchestrator\lib\runTask.js:29:3)
at removeAllListeners (C:\path\to\project\node_modules\karma\lib\server.js:216:7)
at Server.<anonymous> (C:\path\to\project\node_modules\karma\lib\server.js:227:9)
at Server.g (events.js:180:16)

My system is
Windows 7
, nodejs version is
, gulp version:

[10:26:52] CLI version 3.8.8
[10:26:52] Local version 3.8.9

Also, the same error I am getting on
Ubuntu 12.04 LTS
while on newer Ubuntu (not sure what version) and mac os it is seems to be working ok. What can cause this error?

Update 5/11/2016: Before writing comment about the fact that accepted answer hide errors, please, see first two comments to that particular accepted answer. Use it only if know what you are doing. Related info: https://github.com/karma-runner/gulp-karma/pull/15

Answer Source

How are you running your tests with Gulp? I came up against this issue recently on OSX, running node v0.11.14 and gulp 3.8.10, whenever there were failing tests.

Changing from the recommended:

gulp.task('test', function(done) {
        configFile: __dirname + '/karma.conf.js',
        singleRun: true
    }, done);


gulp.task('test', function(done) {
        configFile: __dirname + '/karma.conf.js',
        singleRun: true
    }, function() {

...got rid of this error.

Seems to be down to how gulp handles error messages when an error is signalled in a callback. See Improve error messages on exit for more information.