使用 ESM 时如何让伊斯坦布尔识别代码覆盖率? [英] How do I get Istanbul to recognize code coverage when using ESM?

查看:64
本文介绍了使用 ESM 时如何让伊斯坦布尔识别代码覆盖率?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm using ESM to loading my modules and I use them in this way:

// 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 运行这些测试,但是当我运行伊斯坦布尔时,它似乎无法识别我的导入并且无法提供覆盖信息...

I run these tests using nyc mocha --delay --exit ./test/suite.js, but when I run Istanbul it does not seems to recognize my imports and fails to provide coverage information...

  3 passing (14ms)

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

我怎样才能让伊斯坦布尔识别 ESM 加载 代码?

How can I get Istanbul to recognize the ESM loaded code?

推荐答案

从 Mocha v7.1.0(2020 年 2 月)开始提供原生 ESM 支持.

Native ESM support is available from Mocha v7.1.0 (February 2020).

见:

这篇关于使用 ESM 时如何让伊斯坦布尔识别代码覆盖率?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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