伊斯坦布尔给了我报道但以错误结束输出
Istanbul gives me coverage but ends output with an error
我正在测试一个简单的应用程序(来自此处 https://marcofranssen.nl/using-mocha-chai-sinon-to-test-node-js/ 的 Mocha 教程代码)以尝试让 Istanbul 正常工作。我的问题是 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
没有被识别,因为所有测试 运行 都很好并通过了。
发现问题:mocha 没有全局安装所以我不得不引用它:
istanbul cover /path/to/bin/_mocha path/to/test.js
我正在测试一个简单的应用程序(来自此处 https://marcofranssen.nl/using-mocha-chai-sinon-to-test-node-js/ 的 Mocha 教程代码)以尝试让 Istanbul 正常工作。我的问题是 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
没有被识别,因为所有测试 运行 都很好并通过了。
发现问题:mocha 没有全局安装所以我不得不引用它:
istanbul cover /path/to/bin/_mocha path/to/test.js