default route templateUrl causes unexpected GET error in all module unit test specs #2717
Description
I have an application that is broken down into several modules, each of which defines its own routes to handle and contains several controllers, services...all thru separate files which register themselves to the appropriate module(s).
When I create unit test specs for any particular service, I hit an issue where I get an 'expected GET' request as a result of a templateUrl linked to the default route in the module. I don't expect to have to write an expect in every spec for the route which is completely unrelated to the controller, service, directive...which I am unit testing.
I have created a plunk to test the situation here: http://plnkr.co/edit/jfetatSfBguwEGT59QJ4?p=preview
The actual combination of items that cause such a situation are as follows:
- Create a default route for path '/' AND give it a templateUrl value (using template is not an issue)
- Somewhere in your module chain for which you are unit testing, contain a reference to the $route service
When the above criteria are met, there isn't a good way to separate the unit tests since the module configuration defines route mapping and modules reference to $route initialize code behind the scenes to begin loading the default routes templateUrl thus creating an unexpected GET request for the templateUrl.
The only workaround I have is to explicitly place an $httpBackend.expectGET('path/to/default/template.html') in every test that uses this module reference, but this is not expected and completely unrelated to the test itself.