ngMock does some magic to automatically include itself if you include angular-mocks.js in your index.html.
What's the simplest way to force angular to load a module in test mode simply by including a file and not having to edit any module dependencies.
The only way to load a module is by calling
angular.module(...)
. ngMocks loads "itself" by calling:You don't need to declare a module as a dependency to load it. You can just include
angular.module('<moduleName>', [<moduleDependencies>...]);
in its script.If you mean "how is
ngMock
automagically added to the dependency list of any module loaded usingwindow.module
orangular.mock.module
, it is becausengMocks
creates a custom injector, such that it takes the list of dependencies and prepends'ngMock'
:You could create your own function that prepends your module in the list of dependencies before instantiating, but I hardly believe this will help in testing. On the contrary, it will be one more source of errors (and will result in possibly "hiding" dependency errors).