title: Karma Jasmine testing inject not working
body: <p>I am new to karma unit testing and I have encountered this problem to a simple Ionic Application. </p>
  
  <p>This is my controller:</p>
  
  <pre><code>  angular.module('starter').controller('AccountCtrl', function ($scope) {
  
      $scope.settings = {
        enableFriends: true
      };
  
      $scope.dummyFunction = function () {
        console.log("Just do nothing!");
      }
    });
  </code></pre>
  
  <p>This is my unit testing file:</p>
  
  <pre><code>describe('AccountCtrl', function () {
    var scope, createController;
    beforeEach(module('starter'));
    console.log("0");
  
    beforeEach(function () {
      console.log("1");
    })
  
    beforeEach(inject(function ($rootScope, $controller) {
      console.log("2");
      scope = $rootScope.$new();
      controller = $controller('AccountCtrl', {
        '$scope': scope
      });
    }));
  
    it('should do stuff', function () {
      console.log("3");
      expect("Hello!").toBeDefined();
    });
  
  });
  </code></pre>
  
  <p>At this point, when I run the test I get this:</p>
  
  <pre><code>PhantomJS 2.1.1 (Mac OS X 0.0.0) LOG: 'WARNING: Tried to load angular more than once.'
  
  PhantomJS 2.1.1 (Mac OS X 0.0.0) LOG: '0'
  
  LOG: '1'
  LOG: '3'
  PhantomJS 2.1.1 (Mac OS X 0.0.0) AccountCtrl should do stuff FAILED
      forEach@/Users/eduard.lache/Documents/dummyProjects/unitTestingAPP/www/lib/ionic/js/ionic.bundle.js:13696:24
      loadModules@/Users/eduard.lache/Documents/dummyProjects/unitTestingAPP/www/lib/ionic/js/ionic.bundle.js:17883:12
      createInjector@/Users/eduard.lache/Documents/dummyProjects/unitTestingAPP/www/lib/ionic/js/ionic.bundle.js:17805:30
      workFn@/Users/eduard.lache/Documents/dummyProjects/unitTestingAPP/www/lib/angular-mocks/angular-mocks.js:2353:60
      /Users/eduard.lache/Documents/dummyProjects/unitTestingAPP/www/lib/ionic/js/ionic.bundle.js:17923:53
  PhantomJS 2.1.1 (Mac OS X 0.0.0): Executed 1 of 1 (1 FAILED) ERROR (0.004 secs / 0.011 secs)
  </code></pre>
  
  <p>As you can see from the console.log messages, the inject function is not getting called and the problem is that I don't know why is that and why is this making my test fail as the test expects the string "Hello!" to be defined, which it is.</p>
  
  <p>If I remove the beforeEach that contains the injection the test is successfull.</p>
  
  <p>My goal is to make a test that verifies that $scope.dummyFunction() has been called and that $scope.settings is defined.
  i.e.:</p>
  
  <pre><code>  it('should do stuff', function () {
      var ctrl = controller();
      ctrl.dummyFunction();
      expect(ctrl.dummyFunction).toHaveBeenCalled();
      expect(ctrl.settings).toBeDefined();    
  });
  </code></pre>