(window.beforeEach || window.setup) is not a funct

2019-02-25 18:25发布

问题:

I've tried to setup a testing environment with mocha, phantomjs and istanbul (and grunt). It works great so far, but when it comes to angular-testing i got some problems. I want (and need) to use angular-mocks, but as soon as I include it in my test.html, I get the following console-error in my browser:

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

The matching code in amgular-mocks.js is the following one:

(window.beforeEach || window.setup)(function() {
  annotatedFunctions = [];
  currentSpec = this;
});

This happens both for the current version (1.4.3) and for an old version which apparently worked in another project: 1.3.15.

What am I missing?

回答1:

I fixed it.

The problem was, that i included my librarys (including angular-mocks.js) before mocha.js which apparently doesn't work.