使用MJS和Mocha Delay时如何获得代码覆盖率?

时间:2019-03-10 16:28:35

标签: mocha istanbul ecma

我的代码看起来像这样...

//suite.js
async function wire(){
    await import("./Sanity.spec.mjs"); // eslint-disable-line
    run();
}
wire();

// Sanity.spec.mjs
import chai from "chai";

describe("My Test", ()=>{
    it("Should do what I want",
        ()=>chai.assert.equal(1,1, "One is in fact 1")); // eslint-disable-line no-self-compare
});

我将NODE_OPTIONS设置为--experimental-modules,然后运行npm脚本mocha --delay --exit ./test/suite.js,这运行得很好。问题是我不知道如何增加代码覆盖率。如果我将脚本更改为nyc mocha --delay --exit ./test/suite.js,结果将返回空白...

----------|----------|----------|----------|----------|-------------------|
File      |  % Stmts | % Branch |  % Funcs |  % Lines | Uncovered Line #s |
----------|----------|----------|----------|----------|-------------------|
All files |        0 |        0 |        0 |        0 |                   |
----------|----------|----------|----------|----------|-------------------|

如果我像这样建议其他地方添加@ std / esm nyc -r @std/esm mocha --delay --exit ./test/suite.js,我会得到相同的结果。如何获得适当的代码覆盖率?

我想指出所有这些,尽管这是我的真实套件中的健全性测试,但我还有其他多个测试实际上在测试库类等,并且应该显示覆盖率

0 个答案:

没有答案