I tried to move angular-mock past 1.3.12 and I couldn't so far.
The other packages are sitting at 1.3.14 at the moment but if I run my tests (Karma + Jasmine) with a recent with a recent version of angular-mock I get something like this:
Error: [$injector:modulerr] Failed to instantiate module ng due to:
Error: [$injector:modulerr] Failed to instantiate module ngLocale due to:
RangeError: Maximum call stack size exceeded
at Function.angular.injector.$$annotate (http://localhost:9876/base/tmp/lib/angular-mocks.js:2147:36)
at Function.angular.injector.$$annotate (http://localhost:9876/base/tmp/lib/angular-mocks.js:2147:36)
at Function.angular.injector.$$annotate (http://localhost:9876/base/tmp/lib/angular-mocks.js:2147:36)
at Function.angular.injector.$$annotate (http://localhost:9876/base/tmp/lib/angular-mocks.js:2147:36)
at Function.angular.injector.$$annotate (http://localhost:9876/base/tmp/lib/angular-mocks.js:2147:36)
at Function.angular.injector.$$annotate (http://localhost:9876/base/tmp/lib/angular-mocks.js:2147:36)
at Function.angular.injector.$$annotate (http://localhost:9876/base/tmp/lib/angular-mocks.js:2147:36)
at Function.angular.injector.$$annotate (http://localhost:9876/base/tmp/lib/angular-mocks.js:2147:36)
at Function.angular.injector.$$annotate (http://localhost:9876/base/tmp/lib/angular-mocks.js:2147:36)
at Function.angular.injector.$$annotate (http://localhost:9876/base/tmp/lib/angular-mocks.js:2147:36)
http://errors.angularjs.org/1.3.14/$injector/modulerr?p0=ngLocale&p1=RangeError%3A%20Maximum%20call%20stack%20size%20exceeded%0A%20%20%20%20at%20Function.angular.injector.%24%24annotate%20(http%3A%2F%2Flocalhost%3A9876%2Fbase%2Ftmp%2Flib%2Fangular-mocks.js%3A2147%3A36)%0A%20%20%20%20at%20Function.angular.injector.%24%24annotate%20(http%3A%2F%2Flocalhost%3A9876%2Fbase%2Ftmp%2Flib%2Fangular-mocks.js%3A2147%3A36)%0A%20%20%20%20at%20Function.angular.injector.%24%24annotate%20(http%3A%2F%2Flocalhost%3A9876%2Fbase%2Ftmp%2Flib%2Fangular-mocks.js%3A2147%3A36)%0A%20%20%20%20at%20Function.angular.injector.%24%24annotate%20(http%3A%2F%2Flocalhost%3A9876%2Fbase%2Ftmp%2Flib%2Fangular-mocks.js%3A2147%3A36)%0A%20%20%20%20at%20Function.angular.injector.%24%24annotate%20(http%3A%2F%2Flocalhost%3A9876%2Fbase%2Ftmp%2Flib%2Fangular-mocks.js%3A2147%3A36)%0A%20%20%20%20at%20Function.angular.injector.%24%24annotate%20(http%3A%2F%2Flocalhost%3A9876%2Fbase%2Ftmp%2Flib%2Fangular-mocks.js%3A2147%3A36)%0A%20%20%20%20at%20Function.angular.injector.%24%24annotate%20(http%3A%2F%2Flocalhost%3A9876%2Fbase%2Ftmp%2Flib%2Fangular-mocks.js%3A2147%3A36)%0A%20%20%20%20at%20Function.angular.injector.%24%24annotate%20(http%3A%2F%2Flocalhost%3A9876%2Fbase%2Ftmp%2Flib%2Fangular-mocks.js%3A2147%3A36)%0A%20%20%20%20at%20Function.angular.injector.%24%24annotate%20(http%3A%2F%2Flocalhost%3A9876%2Fbase%2Ftmp%2Flib%2Fangular-mocks.js%3A2147%3A36)%0A%20%20%20%20at%20Function.angular.injector.%24%24annotate%20(http%3A%2F%2Flocalhost%3A9876%2Fbase%2Ftmp%2Flib%2Fangular-mocks.js%3A2147%3A36)
at REGEX_STRING_REGEXP (http://localhost:9876/base/tmp/lib/angular.js:63:12)
at http://localhost:9876/base/tmp/lib/angular.js:4120:15
at forEach (http://localhost:9876/base/tmp/lib/angular.js:323:20)
at loadModules (http://localhost:9876/base/tmp/lib/angular.js:4081:5)
at http://localhost:9876/base/tmp/lib/angular.js:4098:40
at forEach (http://localhost:9876/base/tmp/lib/angular.js:323:20)
at loadModules (http://localhost:9876/base/tmp/lib/angular.js:4081:5)
at Object.createInjector [as injector] (http://localhost:9876/base/tmp/lib/angular.js:4007:11)
at Object.workFn (http://localhost:9876/base/tmp/tools/angular-mocks.js:2354:52)
http://errors.angularjs.org/1.3.14/$injector/modulerr?p0=ng&p1=Error%3A%20%5B%24injector%3Amodulerr%5D%20Failed%20to%20instantiate%20module%20ngLocale%20due%20to%3A%0ARangeError%3A%20Maximum%20call%20stack%20size%20exceeded%0A%20%20%20%20at%20Function.angular.injector.%24%24annotate%20(http%3A%2F%2Flocalhost%3A9876%2Fbase%2Ftmp%2Flib%2Fangular-mocks.js%3A2147%3A36)%0A%20%20%20%20at%20Function.angular.injector.%24%24annotate%20(http%3A%2F%2Flocalhost%3A9876%2Fbase%2Ftmp%2Flib%2Fangular-mocks.js%3A2147%3A36)%0A%20%20%20%20at%20Function.angular.injector.%24%24annotate%20(http%3A%2F%2Flocalhost%3A9876%2Fbase%2Ftmp%2Flib%2Fangular-mocks.js%3A2147%3A36)%0A%20%20%20%20at%20Function.angular.injector.%24%24annotate%20(http%3A%2F%2Flocalhost%3A9876%2Fbase%2Ftmp%2Flib%2Fangular-mocks.js%3A2147%3A36)%0A%20%20%20%20at%20Function.angular.injector.%24%24annotate%20(http%3A%2F%2Flocalhost%3A9876%2Fbase%2Ftmp%2Flib%2Fangular-mocks.js%3A2147%3A36)%0A%20%20%20%20at%20Function.angular.injector.%24%24annotate%20(http%3A%2F%2Flocalhost%3A9876%2Fbase%2Ftmp%2Flib%2Fangular-mocks.js%3A2147%3A36)%0A%20%20%20%20at%20Function.angular.injector.%24%24annotate%20(http%3A%2F%2Flocalhost%3A9876%2Fbase%2Ftmp%2Flib%2Fangular-mocks.js%3A2147%3A36)%0A%20%20%20%20at%20Function.angular.injector.%24%24annotate%20(http%3A%2F%2Flocalhost%3A9876%2Fbase%2Ftmp%2Flib%2Fangular-mocks.js%3A2147%3A36)%0A%20%20%20%20at%20Function.angular.injector.%24%24annotate%20(http%3A%2F%2Flocalhost%3A9876%2Fbase%2Ftmp%2Flib%2Fangular-mocks.js%3A2147%3A36)%0A%20%20%20%20at%20Function.angular.injector.%24%24annotate%20(http%3A%2F%2Flocalhost%3A9876%2Fbase%2Ftmp%2Flib%2Fangular-mocks.js%3A2147%3A36)%0Ahttp%3A%2F%2Ferrors.angularjs.org%2F1.3.14%2F%24injector%2Fmodulerr%3Fp0%3DngLocale%26p1%3DRangeError%253A%2520Maximum%2520call%2520stack%2520size%2520exceeded%250A%2520%2520%2520%2520at%2520Function.angular.injector.%2524%2524annotate%2520(http%253A%252F%252Flocalhost%253A9876%252Fbase%252Ftmp%252Flib%252Fangular-mocks.js%253A2147%253A36)%250A%2520%2520%2520%2520at%2520Function.angular.injector.%2524%2524annotate%2520(http%253A%252F%252Flocalhost%253A9876%252Fbase%252Ftmp%252Flib%252Fangular-mocks.js%253A2147%253A36)%250A%2520%2520%2520%2520at%2520Function.angular.injector.%2524%2524annotate%2520(http%253A%252F%252Flocalhost%253A9876%252Fbase%252Ftmp%252Flib%252Fangular-mocks.js%253A2147%253A36)%250A%2520%2520%2520%2520at%2520Function.angular.injector.%2524%2524annotate%2520(http%253A%252F%252Flocalhost%253A9876%252Fbase%252Ftmp%252Flib%252Fangular-mocks.js%253A2147%253A36)%250A%2520%2520%2520%2520at%2520Function.angular.injector.%2524%2524annotate%2520(http%253A%252F%252Flocalhost%253A9876%252Fbase%252Ftmp%252Flib%252Fangular-mocks.js%253A2147%253A36)%250A%2520%2520%2520%2520at%2520Function.angular.injector.%2524%2524annotate%2520(http%253A%252F%252Flocalhost%253A9876%252Fbase%252Ftmp%252Flib%252Fangular-mocks.js%253A2147%253A36)%250A%2520%2520%2520%2520at%2520Function.angular.injector.%2524%2524annotate%2520(http%253A%252F%252Flocalhost%253A9876%252Fbase%252Ftmp%252Flib%252Fangular-mocks.js%253A2147%253A36)%250A%2520%2520%2520%2520at%2520Function.angular.injector.%2524%2524annotate%2520(http%253A%252F%252Flocalhost%253A9876%252Fbase%252Ftmp%252Flib%252Fangular-mocks.js%253A2147%253A36)%250A%2520%2520%2520%2520at%2520Function.angular.injector.%2524%2524annotate%2520(http%253A%252F%252Flocalhost%253A9876%252Fbase%252Ftmp%252Flib%252Fangular-mocks.js%253A2147%253A36)%250A%2520%2520%2520%2520at%2520Function.angular.injector.%2524%2524annotate%2520(http%253A%252F%252Flocalhost%253A9876%252Fbase%252Ftmp%252Flib%252Fangular-mocks.js%253A2147%253A36)%0A%20%20%20%20at%20REGEX_STRING_REGEXP%20(http%3A%2F%2Flocalhost%3A9876%2Fbase%2Ftmp%2Flib%2Fangular.js%3A63%3A12)%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A9876%2Fbase%2Ftmp%2Flib%2Fangular.js%3A4120%3A15%0A%20%20%20%20at%20forEach%20(http%3A%2F%2Flocalhost%3A9876%2Fbase%2Ftmp%2Flib%2Fangular.js%3A323%3A20)%0A%20%20%20%20at%20loadModules%20(http%3A%2F%2Flocalhost%3A9876%2Fbase%2Ftmp%2Flib%2Fangular.js%3A4081%3A5)%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A9876%2Fbase%2Ftmp%2Flib%2Fangular.js%3A4098%3A40%0A%20%20%20%20at%20forEach%20(http%3A%2F%2Flocalhost%3A9876%2Fbase%2Ftmp%2Flib%2Fangular.js%3A323%3A20)%0A%20%20%20%20at%20loadModules%20(http%3A%2F%2Flocalhost%3A9876%2Fbase%2Ftmp%2Flib%2Fangular.js%3A4081%3A5)%0A%20%20%20%20at%20Object.createInjector%20%5Bas%20injector%5D%20(http%3A%2F%2Flocalhost%3A9876%2Fbase%2Ftmp%2Flib%2Fangular.js%3A4007%3A11)%0A%20%20%20%20at%20Object.workFn%20(http%3A%2F%2Flocalhost%3A9876%2Fbase%2Ftmp%2Ftools%2Fangular-mocks.js%3A2354%3A52)%0A%20%20%20%20at%20attemptSync%20(http%3A%2F%2Flocalhost%3A9876%2Fbase%2Fnode_modules%2Fjasmine-core%2Flib%2Fjasmine-core%2Fjasmine.js%3A1741%3A24)
at REGEX_STRING_REGEXP (http://localhost:9876/base/tmp/lib/angular.js:63:12)
at http://localhost:9876/base/tmp/lib/angular.js:4120:15
at forEach (http://localhost:9876/base/tmp/lib/angular.js:323:20)
at loadModules (http://localhost:9876/base/tmp/lib/angular.js:4081:5)
at Object.createInjector [as injector] (http://localhost:9876/base/tmp/lib/angular.js:4007:11)
at Object.workFn (http://localhost:9876/base/tmp/tools/angular-mocks.js:2354:52)
The code added between 1.3.11 and 1.3.12 is related to those annotated functions. It seems it is entering some sort of infinite loop as soon as is loads the ng module.
Any idea ? Thanks.
This is probably related to https://github.com/angular/angular.js/commit/0baa17a3b7ad2b242df2b277b81cebdf75b04287
@richard-lopes can you plz share a minimal reproduce for this issue? (preferably on plunker or something similar, but a bit more context to what you might be doing differently in your tests might also help)
@richard-lopes Just an idea from looking at the stack - Is it possible that you are loading angular-mocks twice into karma?
Thanks. We have a rather huge project to get something minimal, but I do know is that as soon we have inject() used in a test it will fail with the stack trace I gave here. As soon as I find a minute, I will try to make something minimal.
I am going to check if we do have angular-mocks loaded twice by any chance.
I tried to run the tests with a debugger. The first time it seems to get into the $$annotate function, the annotatedFucntions array is defined and empty.
I can close the issue !
Good call. It was loaded twice indeed.
I was concatenating libraries in a vendor.js file that contained angular-mocks.js as well and also loading it again in Karma from a different location.
So not only getting rid of it from the vendor.js file solved the duplication issue but it also removed that unnecessary payload from the vendor.js served to end users.
Many thanks.
Most helpful comment
@richard-lopes Just an idea from looking at the stack - Is it possible that you are loading angular-mocks twice into karma?