如何用Qunit设置gulp-istanbul?

Mhd*_*Mhd 7 javascript code-coverage qunit istanbul gulp

我正在使用Qunit框架来测试前端Web应用程序.我需要为代码覆盖生成报告.为此,我试图istanbul通过gulp任务使用.我gulpfile.js看起来像:

var gulp = require('gulp'),
    qunit = require('gulp-qunit'),
    istanbul = require('gulp-istanbul');

gulp.task('test1', function() {
    return gulp.src('test/test.html')
        .pipe(qunit());
});

gulp.task('test2', function () {
  return gulp.src('lib/*.js')
    // Covering files
    .pipe(istanbul())
    // Force `require` to return covered files
    .pipe(istanbul.hookRequire());
});

gulp.task('test3', ['test2'], function () {
  return gulp.src('test/test.html')
    .pipe(qunit())
    // Creating the reports after tests ran
    .pipe(istanbul.writeReports())
    // Enforce a coverage of at least 90%
    .pipe(istanbul.enforceThresholds({ thresholds: { global: 90 } }));
});
Run Code Online (Sandbox Code Playgroud)

运行test3将成功完成但代码覆盖率不会.

输出test3:

[16:34:40] Using gulpfile ~\Documents\...\gulpfile.js
[16:34:40] Starting 'test2'...
[16:34:40] Finished 'test2' after 66 ms
[16:34:40] Starting 'test3'...
[16:34:40] Testing test.html
----------|----------|----------|----------|----------|----------------|
File      |  % Stmts | % Branch |  % Funcs |  % Lines |Uncovered Lines |
----------|----------|----------|----------|----------|----------------|
----------|----------|----------|----------|----------|----------------|
All files |      100 |      100 |      100 |      100 |                |
----------|----------|----------|----------|----------|----------------|


=============================== Coverage summary ===============================
Statements   : 100% ( 0/0 )
Branches     : 100% ( 0/0 )
Functions    : 100% ( 0/0 )
Lines        : 100% ( 0/0 )
================================================================================
[16:34:46] Finished 'test3' after 5.11 s
[16:34:47] Took 7ms to run 1 tests. 1 passed, 0 failed.
[16:34:47] gulp-qunit: ? QUnit assertions all passed in test.html
Run Code Online (Sandbox Code Playgroud)

我在这里错过了什么吗?