title: Mocking AngularJS module dependencies in Jasmine unit tests
body: <p>I'm attempting to unit test controller code inside a module that takes other modules as dependencies, but haven't been able to figure out how to mock them properly. </p>
  
  <p>I'm using the Jasmine Framework and running my tests with Karma (Testacular). </p>
  
  <p><strong>Module Code</strong></p>
  
  <pre><code>var app = angular.module('events', ['af.widgets', 'angular-table']);
  
  app.controller('eventsCtrl', function([dependencies]){
      $scope.events = [];
      ...
  });
  </code></pre>
  
  <p><strong>Spec Code</strong></p>
  
  <pre><code>describe('events module', function(){
      var $scope,
          ctrl;
  
      beforeEach(function(){
          angular.mock.module('af.widgets', []);
          angular.mock.module('angular-table', []);
          module('events', ['af.widgets', 'angular-table']);
      });
  
      beforeEach(inject(function($rootScope, $controller){
          $scope = $rootScope.new();
          ctrl = $controller('NameCtrl', {
              $scope: $scope,
          });
      }));
  
      it('should have an empty events array', function(){
          expect($scope.events).toBe([]);
      })
  });
  </code></pre>
  
  <p>The error I'm getting is Karma is "no module af.widgets", so obviously I'm not mocking the module dependencies right. Any hints? </p>