So in my project I'm using only one module everywhere.
Here is how it looks:
angular
.module('moduleToMock', [
'ngAnimate',
'ngAria',
'ngMessages',
'ngRoute',
'ngMaterial',
'md.data.table',
'textAngular',
'ui.utils.masks',
'mp.colorPicker',
'mdPickers',
'ngCookies',
'ngIdle',
'toastr',
'ui.bootstrap',
'ui.bootstrap.typeahead'
])
You see a bunch of services in require section.
Right now I'm going to start writing tests. The error I'm getting is Module 'ngAnimate' is not available
. I already found the same question discussed
So as I see, I should go with something like this:
beforeEach(function(){
module('moduleToMock');
module(function ($provide) {
$provide.value('ngAnimate', module('ngAnimate', []));
$provide.value('ngAria', module('ngAria', []));
$provide.value('ngMessages', module('ngMessages', []));
$provide.value('ngRoute', module('ngRoute', []));
$provide.value('ngMaterial', module('ngMaterial', []));
...
});
});
And this piece of code I have to insert in the beginning of each test of each service, factory, controller and etc.? Is there a way to do not copy-paste it each time I'm writing tests? Most of dependencies I have is not being injected into controllers, just declared as ngModule requirenment.