Reputation: 279
After updating to Angular 1.5.3 (from 1.4.9) all my unit tests have started failing, where they worked before.
The error is as follows:
Error: [$injector:unpr] Unknown provider:
AuthenticationHttpInterceptorProvider
<- AuthenticationHttpInterceptor
<- $http
<- $templateRequest
<- $route
It is expected that the AuthenticationHttpInterceptorProvider is not known at this point, because it is part of a different module which is not unit tested here. If I provide a mock for this interceptor, I get the error that $httpBackend wasn't expecting a GET request for the defined default route.
My question is: Why does $route get loaded in the first place, and how can I prevent it? I'm not unit testing any routes and make no changes to $route after the .config stage in the app where routes are defined. I would expect to never receive any requests for the templateUrls of the views of routes.
I've not been able to find anything in the Angular Changelog that would make me expect a different behaviour with the newer version.
Upvotes: 0
Views: 54
Reputation: 222865
$route
service is forced to be instantiated by ngRoute since 1.5.1:
Ensure
$route
will be instantiated in time to capture the initial$locationChangeSuccess
event. This is necessary in casengView
is ncluded in an asynchronously loaded template.
This is the fix for the issue.
This means that ngRoute
should be a dependency of app routing module, not other tested modules.
Upvotes: 1