首页 > 解决方案 > 使用 ESM 时如何让伊斯坦布尔识别代码覆盖率?

问题描述

我正在使用 ESM 加载我的模块,并以这种方式使用它们:

// More info on why this is needed see (https://github.com/mochajs/mocha/issues/3006)
async function wire(){
    await import("./Sanity.spec.mjs"); 
    await import("./Other.spec.mjs");
    run();
}
wire();

我使用 运行这些测试nyc mocha --delay --exit ./test/suite.js,但是当我运行伊斯坦布尔时,它似乎无法识别我的导入并且无法提供覆盖信息......

  3 passing (14ms)

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

如何让伊斯坦布尔识别ESM 加载的代码?

标签: mocha.jsistanbules6-module-loaderecma

解决方案


Mocha v7.1.0(2020 年 2 月)提供本机 ESM 支持。

看:


推荐阅读