伊斯坦布尔为我提供了覆盖范围,但以错误结束输出 [英] Istanbul gives me coverage but ends output with an error

查看:120
本文介绍了伊斯坦布尔为我提供了覆盖范围,但以错误结束输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在测试一个简单的应用程序(从此处的Mocha教程代码 https://marcofranssen.nl/using-mocha-chai-sinon-to-test-node-js/)来尝试使伊斯坦布尔工作.我的问题是,伊斯坦布尔可以很好地为我提供承保范围摘要,但是由于某种原因,然后吐出了一个错误,我不确定为什么.我的测试全部通过,因此希望它们不是问题.这是我运行伊斯坦布尔的方式:

I'm testing out a simple application (from the Mocha tutorial code here https://marcofranssen.nl/using-mocha-chai-sinon-to-test-node-js/) to try to get Istanbul to work. My problem is that Istanbul works fine to give me a coverage summary, but then spits out an error for some reason and I'm not sure why. My tests all pass so they're hopefully not the problem. Here is how I run Istanbul:

$ istanbul cover test.js

=============================================================================
Writing coverage object [C:\Users\path\test\coverage\coverage.json]
Writing coverage reports at [C:\Users\path\test\coverage]
=============================================================================

=============================== Coverage summary ===============================

Statements   : 54.55% ( 6/11 )
Branches     : 100% ( 0/0 )
Functions    : 0% ( 0/2 )
Lines        : 54.55% ( 6/11 )
================================================================================
ReferenceError: describe is not defined
    at Object.<anonymous> (C:\Users\path\test.js:9:386)
    at Module._compile (module.js:435:26)
    at Object.Module._extensions.(anonymous function) [as .js] (C:\Users\path
\AppData\Roaming\npm\node_modules\istanbul\lib\hook.js:107:24)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:311:12)
    at Function.Module.runMain (module.js:467:10)
    at runFn (C:\Users\path\AppData\Roaming\npm\node_modules\istanbul\lib\com
mand\common\run-with-cover.js:122:16)
    at C:\Users\path\AppData\Roaming\npm\node_modules\istanbul\lib\command\co
mmon\run-with-cover.js:251:17
    at C:\Users\path\AppData\Roaming\npm\node_modules\istanbul\lib\util\file-
matcher.js:68:16
    at C:\Users\path\AppData\Roaming\npm\node_modules\istanbul\node_modules\a
sync\lib\async.js:52:16

我不太确定为什么describe不能被识别,因为所有测试都能正常运行并通过.

I'm not too sure why describe is not recognized as all the tests run fine and pass.

推荐答案

发现了问题:未在全球范围内安装摩卡,所以我必须引用它:

Found the problem: mocha wasn't installed globally so I had to reference it:

istanbul cover /path/to/bin/_mocha path/to/test.js

这篇关于伊斯坦布尔为我提供了覆盖范围,但以错误结束输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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