Karma测试运行良好,但如果运行0 of 0测试,则会退出并显示代码1。谁知道在这种情况下如何返回退出代码0并正常退出?使用gulp-karma,它会在没有运行规范时使任务失败。
发布于 2015-02-16 05:14:16
在您的gulp文件中,将您的gulp测试任务中错误回调中的“抛出错误”替换为"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;
});
});所以你的测试任务现在看起来是这样的;
gulp.task('test', function() {
return gulp.src(testFiles)
.pipe(karma({
configFile: 'karma.conf.js',
action: 'run'
}))
.on('error', function(err) {
this.emit('end');
});
});发布于 2016-08-16 19:37:00
有一个允许空测试套件的configuration option。只需添加
failOnEmptyTestSuite: false添加到您的karma.conf.js,进程将退出,并返回退出代码0。
BR克里斯
https://stackoverflow.com/questions/28348153
复制相似问题