title: ui-router causing "full page reload" in controller test?
body: <p>I'm trying to write some angular controller tests but ran into:</p>
  
  <p><code>Some of your tests did a full page reload!</code> </p>
  
  <p>karma/jasmine error as soon as my test ran <code>httpMock.flush()</code></p>
  
  <p>After troubleshooting by removing code from my controller and it's corresponding test piece by piece until it passed, I discovered that the test would pass if I removed $state dependency so the error was somehow related to ui-router.  </p>
  
  <p>After more digging it appears to be related to the inclusion of $urlRouterProvider in my routes file:</p>
  
  <pre><code>App.config(function($stateProvider, $urlRouterProvider) {
   // For any unmatched url, redirect to
   $urlRouterProvider.otherwise('dashboard');
  </code></pre>
  
  <p>$urlRouterProvider produces window.location.  If I remove $urlRouterProvider.otherwise line, I can put back $state and the tests pass.  </p>
  
  <p>EDIT:</p>
  
  <p>After more digging.</p>
  
  <p>I did end up finding that we were doing a full page redirect somewhere else in <code>$rootScope.$on('$stateChangeStart')</code> checking to see if a cookie existed or to log the user out.  </p>
  
  <p>But even upon commenting that out, I get a new error: unexpected GET request for the template of the dashboard view.  I figured maybe my test doesn't pass any values to the ui-router mechanism (I was just passing $state through) so it doesn't know what the state is and therefore triggers the <code>$urlRouterProvider.otherwise</code> route.  So I added a <code>state.transitionTo('base.settings.sales-channels.edit', {channelId:1});</code> in my test.  This is a nested state.  </p>
  
  <p>This indeed changes the error message to <code>Error: Unexpected request: GET ../src/settings/index.tpl.html</code>, which looks like it's the template for the parent state since <code>settings</code> comes before <code>sales-channels</code>, which comes before <code>edit</code> in my state name.  </p>
  
  <p>Why do I get this error?  Do we have to mock out expectations for all the parent state's templates? </p>
  
  <p>EDIT</p>
  
  <p>Here is a plunkr the reproduces the test error I am getting
  <a href="http://plnkr.co/edit/DoaIBqK1JMqbTJj3vlmH?p=preview" rel="nofollow">http://plnkr.co/edit/DoaIBqK1JMqbTJj3vlmH?p=preview</a></p>
  
  <p>EDIT</p>
  
  <p>Looks like the template GET request is a known issue:  <a href="https://github.com/angular-ui/ui-router/issues/212" rel="nofollow">https://github.com/angular-ui/ui-router/issues/212</a></p>
  
  <p>I implemented the state mock method mentioned in that issue and the unit tests pass now.</p>