title: AngularJS Karma test - Resolve object passed into controller is undefined when testing
body: <p>We are using ui-router 0.2.10.</p>
  
  <p>I am injecting a resolve object as a parameter into my controller, which is then setting a scope variable in the controller. It works perfectly on the app like so:</p>
  
  <p><strong>state provider</strong></p>
  
  <pre><code>$stateProvider.state('myState', {
        resolve:{
           foo:  function(){
              return 'bar';
           },
        url: '/',
        templateUrl: 'index.html',
        controller: 'FooCtrl'
     })
  </code></pre>
  
  <p><strong>controller</strong></p>
  
  <pre><code>app.Controllers.controller('FooCtrl', ['$scope', '$state', 'foo',
      function ($scope, $state, $log, Zone, foo) {
          $scope.testVar = foo
          console.log($scope.testVar);
      }])
  </code></pre>
  
  <p>'Bar' is then logged to the console as expected in Chrome.</p>
  
  <p>But when running tests using Karma, the resolve object is now undefined, which fails the test. Here is the test code: </p>
  
  <pre><code>describe('controllers', function(){
  
    var $rootScope, 
        $scope,
        $state
  
    beforeEach(module('app'))
  
    beforeEach(inject(function($injector) {
      $state = $injector.get('$state')
      $rootScope = $injector.get('$rootScope')
      $scope = $rootScope.$new()
      $controller = $injector.get('$controller')
    }))
  
    it('FooCtrl should exist', inject( function() {
      $state.go('myState')
      $rootScope.$apply()
  
      $controller = $controller('FooCtrl', {
        '$scope': $scope
      })
      $rootScope.$apply()
  
      assert.equal($scope.testVar, "bar", "these strings are equal")
    }))
  })
  </code></pre>
  
  <p>This error is presented (the resolve object in my case is called resolvedRouteModels):</p>
  
  <pre><code>[$injector:unpr] Unknown provider: fooProvider &lt;- foo
      http://errors.angularjs.org/1.3.0-build.2921+sha.02c0ed2/$injector/unpr?p0=fooProvider%20%3C-%20foo
  </code></pre>
  
  <p>Any help would be much appreciated, and please let me know if you have encountered this problem. </p>