angularjs - ngMock is throwing template load error because of ngRoute's $routeProvider...? -
I just include ngMock in my project because I need $ httpBackend for this I have a bunch of Karma / Jasmine tests , And after adding NMMock, it is breaking due to an error:
PhantomJS 1.9.7 (Windows 7): 41 successfully executed (0 seconds / 0 seconds) phantamJS 1.9 .7 (Windows 7) Error Error: Unexpected Request: Get Home / HomeOct C: / dev / app / bower_components / angular-mocks / angular-mocks Do not expect more requests at .js: 1181
It seems that it does not like the NGRUT / $ route provider, in particular it breaks otherwise / redirects on the Toto Statement. . If I comment on that section, the Karma / Jaskar test works without any errors.
$ route provider. When ('/ house', angularAMD.route ({templateUrl: 'home / home.html', controller: ''})). Otherwise ({redirectTo: '/ home'}); Notice, I am using angularAMD to load lazy, but whenever I rewrite that segment with just {} without angularAMD.route (), it throws the same error. I.e.: $ routeProvider. When ('/ home', {templateUrl: 'home / home.html', controller: ''}). Otherwise ({redirectTo: '/ home'});
Any ideas why not like ngMock ngRoute? For now I have made an alternate solution, where I leave the $ route provider section while running the Karma / Jaskar test. But I'm trying to understand what's going on, do I not want to set the $ route provider at the unit test (this is bad behavior)?
[edit:] Issues are also seen in other areas. I'm running a test that includes a service that is loading a template, and also throws an error:
Error: Unexpected request: Get component / modal / modal. $ HttpBackend at (C: /dev/app/bower_components/angular-mocks/angular-mocks.js: 1181)
[edit:] The error is when I call $ httpBackend.flush (); [edit]] The great post related to the release can not believe that Google did not show any relevant results when I searched. Solution: If you get yourself from Google results, take a look at these:,. [EDIT:] Any suggestions on angularAMD working with those solutions?
My issue was that I was not loading the full module for the app (which is what I NgRoute was added).
In my User.tests.js
file, I had
first (module ('apps.' ')');
In my app.js
file I had:
app = angular. Modules ("App", ["ng root" "App.templates" "App.filters" "App.services" "App.controllers" "App.directives" "ui.bootstrap"]);
In my User.js
service, I was actually using $ route
. My User.tests.js
switch to use the fake module "app"
- for Solutions my To do - beforeEach (module ("app"))
; Testing in this way all right dependencies are loaded.
Comments
Post a Comment