Unknown Provider error while unit testing in jasmine

445 Views Asked by At

I have a module as below in a js file

app.js

 angular.module( 'app', [ 'ui.bootstrap', 'routes', 'module2', 'ngAnimate', 'ngSanitize' ] );

If i am to write a unit test case then how should i load the modules in my unit test case??

Is it this way

module('app');

Other way

module('ui.bootstrap');
module('routes');
module('module2');
module('ngAnimate');
module('ngSanitize');

Which is right order or the right way to load the module...As am always getting the below error

Error: [$injector:unpr] Unknown provider: deepakProvider <- deepak
 http://errors.angularjs.org/1.4.9/$injector/unpr?p0=deepakProvider%20%3C-%20deepak
     at C:/jasmine/InformedEnrollment2/src/webapp/informedenrollment2/webclnt/components/angular/angular.js:68:12
     at C:/jasmine/project/src/webapp/project/webclnt/components/angular/angular.js:4346:19
     at Object.getService [as get] (C:/jasmine/project/src/webapp/project/webclnt/components/angular/angular.js:4494:39)
     at C:/jasmine/project/src/webapp/project/webclnt/components/angular/angular.js:4351:45
     at Object.getService [as get] (C:/jasmine/project/src/webapp/project/webclnt/components/angular/angular.js:4494:39)
     at Object.<anonymous> (C:/jasmine/project/tests/DemoToTheTeam.js:20:47)
     at Object.invoke (C:/jasmine/project/src/webapp/project/webclnt/components/angular/angular.js:4535:17)
     at Object.workFn (C:/jasmine/project/node_modules/angular-mocks/angular-mocks.js:3071:20)
 Error: Declaration Location
     at window.inject.angular.mock.inject (C:/jasmine/project/node_modules/angular-mocks/angular-mocks.js:3033:25)
     at Suite.<anonymous> (C:/jasmine/project/tests/DemoToTheTeam.js:19:15)
     at C:/jasmine/project/tests/DemoToTheTeam.js:2:1
 TypeError: Cannot read property 'multiply' of undefined
     at Object.<anonymous> (C:/jasmine/project/tests/DemoToTheTeam.js:26:13)
50.0.2661 (Windows 7 0.0.0): Executed 7 of 7 (1 FAILED) (0.182 secs / 0.064 secs)
0

There are 0 best solutions below