istanbul + mocha + chai 跑覆盖率的时候提示`describe is not defined`

hubery
  • 794

RT,我在全局当前项目都安装了5.0.0版本的mocha以及最新版本istanbul,但是不管是跑
./node_modules/.bin/istanbul cover ./test/index.test.js 还是 istanbul cover ./test/index.test.js 都提示我

/Users/hubery/workspace/repos/torch/test/index.test.js:4
describe('the basic usage of Promise', function() {
^

ReferenceError: describe is not defined
    at Object.<anonymous> (/Users/hubery/workspace/repos/torch/test/index.test.js:4:1)
    at Module._compile (module.js:635:30)
    at Object.Module._extensions..js (module.js:646:10)
    at Object.Module._extensions.(anonymous function) [as .js] (/Users/hubery/workspace/repos/torch/node_modules/istanbul/lib/hook.js:109:37)
    at Module.load (module.js:554:32)
    at tryModuleLoad (module.js:497:12)
    at Function.Module._load (module.js:489:3)
    at Function.Module.runMain (module.js:676:10)
    at runFn (/Users/hubery/workspace/repos/torch/node_modules/istanbul/lib/command/common/run-with-cover.js:122:16)
    at /Users/hubery/workspace/repos/torch/node_modules/istanbul/lib/command/common/run-with-cover.js:251:17

请问如何解决?

回复
阅读 2.8k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
宣传栏