2

一般刚开始使用代码覆盖工具,但我认为我已经正确设置了所有内容。但是,Istanbul 正在生成我的规范文件而不是源文件的覆盖率报告?

当我跑步时jasmine-node repeatSpec.js --verbose

我得到:

 repeat Start
    repeats strings - 1 ms
  repeat Finish - 3 ms



Finished in 0.004 seconds
1 Tests, 0 Failures, 0 Skipped

这是正确的,如果我故意使测试失败,它也会正确失败。

但是,当我运行这个 istanbul 命令时:

 istanbul cover  /d/Users/rkan/AppData/Roaming/npm/node_modules/jasmine-node/bin/jasmine-node  repeatSpec.js

我得到了这个响应,它正在根据我的规范文件检查覆盖率。

=============================================================================
Writing coverage object [d:\playground\ue\node\Domain\WorkQueue\tests\coverage\coverage.json]
Writing coverage reports at [d:\playground\ue\node\Domain\WorkQueue\tests\coverage]
=============================================================================

=============================== Coverage summary ===============================
Statements   : 100% ( 5/5 )
Branches     : 100% ( 0/0 )
Functions    : 100% ( 2/2 )
Lines        : 100% ( 5/5 )
================================================================================

我做错了什么?

谢谢!

nb - 文件目录是这样的

|
|-lib/repeat.js
|
|-tests/repeatSpec.js
|

重复.js

if (! String.prototype.repeat) {
        String.prototype.repeat = function (times) {
            return new Array(times+1).join(this);
        }
    }
if (x=68){
    x = 2;
}

if (x=200){
    x =5;
}

重复规范.js

require("../lib/repeat.js");

    describe("repeat", function() {
        it("repeats strings", function() {
            expect("abc".repeat(2)).toEqual("abcabc");
            expect("abc".repeat(0)).toEqual("");
        });
    });
4

1 回答 1

0

确保将mask: '*.spec.js'选项传递给您的伊斯坦布尔选项配置对象。

于 2015-09-08T15:26:08.650 回答