充分吞噬伊斯坦布尔覆盖报告 [英] Full Gulp Istanbul Coverage Report

查看:195
本文介绍了充分吞噬伊斯坦布尔覆盖报告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用gulp-istanbul通过Gulp生成JavaScript单元测试覆盖率报告。有没有一种方法可以配置伊斯坦布尔来生成我的gulp流中所有JS文件的完整覆盖报告,而不仅仅是测试用例触及的文件。



I我正在研究一个有很多JS的项目,但没有进行单元测试,我们正在尝试增加测试覆盖率。我想有一个覆盖面报告,首先显示大部分文件的覆盖率为0%,但随着时间的推移,覆盖率会有所增加。

  gulp.task('test',function(){
gulp.src([my source glob])
.pipe(istanbul())
.on(' ($ {
记者:'spec'
}))$ b(函数(){
gulp.src([my test spec glob])
.pipe $ b .pipe(istanbul.writeReports(
[output location]
));
});
});


解决方案

现在它实际上更简单了,向 istanbul()呼叫中添加 includeUntested



<$ ('./ assets / ** / js / *。js')
('test',function(){
return gulp.src $ {
.ipe(istanbul({includeUntested:true}))
.on('finish',function(){
gulp.src('./ assets / js / ($记者:'spec'}))
.pipe(istanbul.writeReports({
dir:'./assets/unit-测试覆盖率',
记者:['lcov'],
reportOpts:{dir:'./assets/unit-test-coverage'}
}));
});
});

来源: https://github.com/SBoudrias/gulp-istanbul#includeuntested


I am using gulp-istanbul to generate JavaScript unit test coverage reports through Gulp. Is there a way to configure Istanbul to generate a full coverage report of all the JS files in my gulp stream, and not just the files touched by a test case.

I'm working on a project with a lot of JS, but no unit tests, and we are trying to increase the test coverage. I would like to have a coverage report that starts by show 0% coverage for most of our files, but over time will present an increasing coverage percentage.

gulp.task( 'test', function () {
    gulp.src( [ my source glob ] )
        .pipe( istanbul() )
        .on( 'end', function () {
            gulp.src( [ my test spec glob ] )
                .pipe( mocha( {
                    reporter: 'spec'
                } ) )
                .pipe( istanbul.writeReports(
                    [ output location ]
                ) );
        } );
} );

解决方案

It actually is much more simple now and you just have to add includeUntested to your istanbul() call.

gulp.task('test', function () {
    return gulp.src('./assets/**/js/*.js')
      // Right there
      .pipe(istanbul({includeUntested: true}))
      .on('finish', function () {
        gulp.src('./assets/js/test/test.js')
          .pipe(mocha({reporter: 'spec'}))
          .pipe(istanbul.writeReports({
            dir: './assets/unit-test-coverage',
            reporters: [ 'lcov' ],
            reportOpts: { dir: './assets/unit-test-coverage'}
          }));
      });
  });

Source : https://github.com/SBoudrias/gulp-istanbul#includeuntested

这篇关于充分吞噬伊斯坦布尔覆盖报告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆