title: Testing a controller not using $scope using karma
body: <p>I followed the instructions on <a href="https://docs.angularjs.org/guide/unit-testing" rel="nofollow">docs.angularjs.org</a> to test a controller with karma and it's perfectly working.
  However I was wondering if it's possible to test a controller which is not using $scope?</p>
  
  <p>Testing this controller is ok:</p>
  
  <pre><code>angular.module('starter.controllers')
  .controller('PasswordController', function PasswordController($scope)
  {
      $scope.password = '';
      $scope.grade = function()
      {
          var size = $scope.password.length;
          if (size &gt; 8) {
              $scope.strength = 'strong';
          } else if (size &gt; 3) {
              $scope.strength = 'medium';
          } else {
              $scope.strength = 'weak';
          }
      };
  });
  </code></pre>
  
  <p>But I'd like to test:</p>
  
  <pre><code>angular.module('starter.controllers')
  .controller('PasswordController', function PasswordController()
  {
      var myController = this;
      myController.password = '';
      myController.grade = function()
      {
          var size = myController.password.length;
          if (size &gt; 8) {
              myController.strength = 'strong';
          } else if (size &gt; 3) {
              myController.strength = 'medium';
          } else {
              myController.strength = 'weak';
          }
      };
  });
  </code></pre>
  
  <p>The testing code is the following:</p>
  
  <pre><code>describe('PasswordController', function()
  {
      beforeEach(module('starter.controllers'));
  
      var $controller;
  
      beforeEach(inject(function(_$controller_){
          $controller = _$controller_;
      }));
  
      describe('$scope.grade', function() {
          var $scope, controller;
  
          beforeEach(function() {
              $scope = {};
              //This line doesn't work with the second controller
              controller = $controller('PasswordController', { $scope: $scope});
          });
  
          it('sets the strength to "strong" if the password length is &gt;8 chars', function() {
              $scope.password = 'longerthaneightchars';
              $scope.grade();
              expect($scope.strength).toEqual('strong');
          });
      });
  });
  </code></pre>