mocha.js - 使用 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 v7.1.0(2020 年 2 月)提供本机 ESM 支持。
看:
推荐阅读
- typescript - 我在 typeorm 中对数组进行过滤时遇到问题。QueryBuilder 只返回它找到的第一个匹配项
- vue.js - Vue Accordion:覆盖 SCSS 值
- neo4j - Neo4j 计算关系
- view - 从多个列标题创建切片器
- flutter - 连接服务协议出错:无法连接到http://127.0.0.1:58463/vWu5Xiui7n4=/
- java - Java代码显示到下一个闰年的年数
- python - 用新的数据框更新数据框,覆盖
- button - 如何根据页面语言更改按钮位置?
- r - 使用 ggplot 按百分比显示直方图
- python - 如何让使用正则表达式匹配年份和月份?