(window.beforeEach || window.setup)不是函数

jul*_*com 2 javascript testing mocha.js phantomjs angularjs

我试图用mocha,phantomjs和istanbul(以及grunt)设置测试环境.它到目前为止工作得很好,但是当谈到角度测试时我遇到了一些问题.我想(并且需要)使用角度模拟,但是只要我将其包含在我的test.html中,我的浏览器就会出现以下控制台错误:

Uncaught TypeError: (window.beforeEach || window.setup) is not a function

amgular-mocks.js中的匹配代码如下:

(window.beforeEach || window.setup)(function() {
  annotatedFunctions = [];
  currentSpec = this;
});
Run Code Online (Sandbox Code Playgroud)

对于当前版本(1.4.3)和显然在另一个项目中工作的旧版本都会发生这种情况:1.3.15.

我错过了什么?

jul*_*com 6

我修好了它.

问题是,我包括我的图书馆(包括angular-mocks.js),之前 mocha.js显然不起作用.

  • 注意:angular-mocks.js实际上需要在<script> mocha.setup('bdd'); </ script>之后,而不仅仅是在mocha.js之后.请参阅Adam Brown在http://stackoverflow.com/questions/35461233/why-am-i-getting-this-angular-mock-error-and-mocha-test-is-not-running上的回答. (4认同)