0

我使用带有 AMD 样式模块的 Backbone/Marionette 和 RequireJS 编写了一个应用程序,并尝试向它添加一个覆盖步骤,但是,在运行时istanbul cover myTestFile.js,istanbul 会抛出此错误:

__cov_EsyvGtIcLKP7TgjU5WMSQw.s['1']++;定义(函数(要求){__cov_EsyvGtIcL define is not defined

我不知道如何解决这个问题,因为我从未覆盖过浏览器端代码,这是我第一次使用 AMD 样式模块。

伊斯坦布尔还说已经写了一份覆盖报告,所以我不明白这是否意味着它实际上运行成功了。

任何指针都会有很大帮助。这是istanbul cover mytestfile.js命令的完整输出(更改了一些细节):

=============================================================================
Writing coverage object [/Users/myuser/src/myapp/coverage/coverage.json]
Writing coverage reports at [/Users/myuser/src/myapp/coverage]
=============================================================================

=============================== Coverage summary ===============================
Statements   : 5% ( 1/20 )
Branches     : 0% ( 0/2 )
Functions    : 0% ( 0/5 )
Lines        : 5% ( 1/20 )
================================================================================
/Users/myuser/src/myapp/app/myapp/app-collection.js:9
__cov_EsyvGtIcLKP7TgjU5WMSQw.s['1']++;define(function(require){__cov_EsyvGtIcL
                                      ^
ReferenceError: define is not defined
    at Object.<anonymous> (/Users/mysuser/src/myapp/app/myapp/app-collection.js:9:39)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions.(anonymous function) [as .js] (/usr/local/lib/node_modules/istanbul/lib/hook.js:107:24)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object.<anonymous> (/Users/myuser/src/myapp/test/specs/applications-tests.js:9:25)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
4

0 回答 0