Karma exits with code 1 when it does not perform any special tests

The Karma test works fine, but exits with code 1 if tests of 0 of 0 are running. Does anyone know how to return exit code 0 and exit normally in this case? Using gulp-karma , which does not complete the task when specifications do not start.

+8
karma-runner karma-jasmine gulp-karma
source share
2 answers

In your gulpfile, replace "throw err" with the error callback in your gulp test task with "this.emit (" end ")".

 gulp.task('test', function() { return gulp.src(testFiles) .pipe(karma({ configFile: 'karma.conf.js', action: 'run' })) .on('error', function(err) { throw err; }); }); 

so your test task now looks like this:

 gulp.task('test', function() { return gulp.src(testFiles) .pipe(karma({ configFile: 'karma.conf.js', action: 'run' })) .on('error', function(err) { this.emit('end'); }); }); 
+2
source share

There is a configuration parameter that allows empty test suites. Just add

 failOnEmptyTestSuite: false 

to your karma.conf.js , and the process ends with exit code 0.

BR Chris

+14
source share

All Articles