lundi 22 décembre 2014

Why this error when I ride my test with karma?

What can cause this error?



Error: [$injector:modulerr] Failed to instantiate module fooApp due to:
TypeError: 'undefined' is not a function (evaluating '$stateProvider
.state')


My service(Provider) :



'use strict';

angular.module('fooApp')
.factory('MyService', function () {

var function1 = function function1(value) {
return value;
};

return {
function1: function1
};
});


my test :



'use strict';

describe('Service: MyService', function () {
beforeEach(module('fooApp'));

var MyService;

beforeEach(function(){
inject(function ($injector) {
MyService= $injector.get('MyService');
});
});

it('should ....', function(){
expect(MyService.function1('....')).toEqual(...);
.....
});
......
});


foo.js :



'use strict';

angular.module('fooApp')
.config(function ($stateProvider) {
$stateProvider
.state('foo', {
url: '/foo',
views: {
'content': {
templateUrl: 'app/foo/foo.html',
controller: 'FooCtrl'
},
'footer': {
templateUrl: 'components/footer/footer.html',
line 15: controller: 'FooterCtrl'
}
}
});
});


stacktrace :



Error: [$injector:modulerr] Failed to instantiate module fooApp due to:
TypeError: 'undefined' is not a function (evaluating '$stateProvider
.state')
at C:/_Projet/foo/client/app/foo/foo.js:15
at invoke (C:/_Projet/foo/client/bower_components/angular/angular.js:4182)
at runInvokeQueue (C:/_Projet/foo/client/bower_components/angular/angular.js:4088)
at C:/_Projet/foo/client/bower_components/angular/angular.js:4097
at forEach (C:/_Projet/foo/client/bower_components/angular/angular.js:323)
at loadModules (C:/_Projet/foo/client/bower_components/angular/angular.js:4120)
at createInjector (C:/_Projet/foo/client/bower_components/angular/angular.js:4004)
at workFn (C:/_Projet/foo/client/bower_components/angular-mocks/angular-mocks.js:2339)
http://ift.tt/1xEri1O'undefined'%20is%20not%20a%20function%20(evaluating%20'%24stateProvider%0A%20%20%20%20%20%20%20%20%20%20%20%20.state')%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A8080%2Fbase%2Fclient%2Fapp%2Fauth%2Fauth.js%3Fb8f7bccdf2d8f57e6d6f0c810e0d1c6f0d3df707%3A15%0A%20%20%20%20at%20invoke%20(http%3A%2F%2Flocalhost%3A8080%2Fbase%2Fclient%2Fbower_components%2Fangular%2Fangular.js%3Febb86f089066f7089a249e390e64bcab67622158%3A4182)%0A%20%20%20%20at%20runInvokeQueue%20(http%3A%2F%2Flocalhost%3A8080%2Fbase%2Fclient%2Fbower_components%2Fangular%2Fangular.js%3Febb86f089066f7089a249e390e64bcab67622158%3A4088)%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A8080%2Fbase%2Fclient%2Fbower_components%2Fangular%2Fangular.js%3Febb86f089066f7089a249e390e64bcab67622158%3A4097%0A%20%20%20%20at%20forEach%20(http%3A%2F%2Flocalhost%3A8080%2Fbase%2Fclient%2Fbower_components%2Fangular%2Fangular.js%3Febb86f089066f7089a249e390e64bcab67622158%3A323)%0A%20%20%20%20at%20loadModules%20(http%3A%2F%2Flocalhost%3A8080%2Fbase%2Fclient%2Fbower_components%2Fangular%2Fangular.js%3Febb86f089066f7089a249e390e64bcab67622158%3A4120)%0A%20%20%20%20at%20createInjector%20(http%3A%2F%2Flocalhost%3A8080%2Fbase%2Fclient%2Fbower_components%2Fangular%2Fangular.js%3Febb86f089066f7089a249e390e64bcab67622158%3A4004)%0A%20%20%20%20at%20workFn%20(http%3A%2F%2Flocalhost%3A8080%2Fbase%2Fclient%2Fbower_components%2Fangular-mocks%2Fangular-mocks.js%3Fb01a9cf8de7de4def103da067347cb07fe247c96%3A2339)%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A8080%2Fbase%2Fnode_modules%2Fkarma-jasmine%2Flib%2Fjasmine.js%3F437512c57124d57f5ec77e2e82bfb4e3cdd15cce%3A1145%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A8080%2Fbase%2Fnode_modules%2Fkarma-jasmine%2Flib%2Fjasmine.js%3F437512c57124d57f5ec77e2e82bfb4e3cdd15cce%3A2177%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A8080%2Fbase%2Fnode_modules%2Fkarma-jasmine%2Flib%2Fjasmine.js%3F437512c57124d57f5ec77e2e82bfb4e3cdd15cce%3A2130%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A8080%2Fbase%2Fnode_modules%2Fkarma-jasmine%2Flib%2Fjasmine.js%3F437512c57124d57f5ec77e2e82bfb4e3cdd15cce%3A2460%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A8080%2Fbase%2Fnode_modules%2Fkarma-jasmine%2Flib%2Fjasmine.js%3F437512c57124d57f5ec77e2e82bfb4e3cdd15cce%3A2177%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A8080%2Fbase%2Fnode_modules%2Fkarma-jasmine%2Flib%2Fjasmine.js%3F437512c57124d57f5ec77e2e82bfb4e3cdd15cce%3A2130%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A8080%2Fbase%2Fnode_modules%2Fkarma-jasmine%2Flib%2Fjasmine.js%3F437512c57124d57f5ec77e2e82bfb4e3cdd15cce%3A2606%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A8080%2Fbase%2Fnode_modules%2Fkarma-jasmine%2Flib%2Fjasmine.js%3F437512c57124d57f5ec77e2e82bfb4e3cdd15cce%3A2177%0A%20%20%20%20at%20http%3A%2F%2Flocalhost%3A8080%2Fbase%2Fnode_modules%2Fkarma-jasmine%2Flib%2Fjasmine.js%3F437512c57124d57f5ec77e2e82bfb4e3cdd15cce%3A2167
at C:/_Projet/foo/client/bower_components/angular/angular.js:4118
at forEach (C:/_Projet/foo/client/bower_components/angular/angular.js:323)
at loadModules (C:/_Projet/foo/client/bower_components/angular/angular.js:4120)
at createInjector (C:/_Projet/foo/client/bower_components/angular/angular.js:4004)
at workFn (C:/_Projet/foo/client/bower_components/angular-mocks/angular-mocks.js:2339)


Bower.js :



{
"dependencies": {
"angular": "~1.3.7",
"jquery": "~2.1.1",
"json3": "~3.3.1",
"es5-shim": "~3.0.1",
"bootstrap-sass-official": "~3.1.1",
"bootstrap": "~3.3.1",
"angular-resource": "~1.3.6",
"angular-cookies": "~1.3.6",
"angular-sanitize": "~1.3.6",
"angular-bootstrap": "0.11.2",
"angular-translate-loader-partial": "2.5.2",
"angular-translate-storage-local": "2.5.2",
"font-awesome": "~4.1.0",
"lodash": "~2.4.1",
"angular-ui-router": "~0.2.11",
"angular-ui-calendar": "~0.8.*",
"metisMenu": "~1.1.3",
"restangular": "~1.4.0",
"blueimp-md5": "1.1.0",
"angular-cookie": "~4.0.6",
"angular-datatables": "~0.3.0",
"angular-ui-select": "0.9.5"
},
"devDependencies": {
"angular-mocks": "~1.3.8",
"angular-scenario": "~1.3.8"
}


}


Aucun commentaire:

Enregistrer un commentaire