I looked at Angular source code and it seems both angular.mock.inject
and angular.mock.module
are undefined unless using Jasmine or Mocka.
It seems the solution to the problem is to either manually create an injector for every test case or manually patch angular-mocks.js
to make it testing framework agnostic (which should be the case IMHO):
--- angular-mocks.js 2014-03-19 07:12:40.194522300 +0100
+++ angular-mocks2.js 2014-03-19 07:12:32.344002500 +0100
@@ -1917,11 +1917,24 @@
-if(window.jasmine || window.mocha) {
+if ( window.jasmine || window.mocha || window.QUnit ) {
var currentSpec = null,
isSpecRunning = function() {
- return currentSpec && (window.mocha || currentSpec.queue.running);
+ if ( window.mocha ) {
+ return currentSpec && true;
+ } else if ( window.jasmine ) {
+ return currentSpec && currentSpec.queue.running;
+ } else if ( window.QUnit ) {
+ return currentSpec && currentSpec.config.queue.length > 0;
+ }
};
+ if ( window.QUnit ) {
+ var beforeEach = testStart;
+ var afterEach = testDone;
+ var modulefunction = "ngmodule";
+ } else {
+ var modulefunction = "module";
+ }
beforeEach(function() {
@@ -1974,5 +1987,5 @@
* the module name and the value being what is returned.
*/
- window.module = angular.mock.module = function() {
+ window[modulefunction] = angular.mock.module = function() {
var moduleFns = Array.prototype.slice.call(arguments, 0);
return isSpecRunning() ? workFn() : workFn;