title: TypeError: scope is undefined Karma-jasmine-angular unit testing
body: <p>I am new with <strong>karma-jasmine</strong> and trying to develop a demo test case. I am getting error of <strong>scope is not defined</strong> in <strong>'it'</strong>. I have read the following links with same problem but it's not helping me with my test case. </p>
  
  <p><a href="https://stackoverflow.com/questions/27630899/error-karma-undefined-scope-variable-in-beforeeach">Error Karma &#39;undefined&#39; scope variable in beforeEach</a></p>
  
  <p><a href="https://stackoverflow.com/questions/22849953/typeerror-scope-is-undefined-in-angular-controller-unit-test-with-jasmine">TypeError: $scope is undefined in Angular controller unit test with Jasmine</a></p>
  
  <blockquote>
    <p>This is my <strong>karma.conf.js</strong></p>
  </blockquote>
  
  <pre><code> module.exports = function(config) {
        config.set({
  
      exclude)
          basePath: '',
  
  
          frameworks: ['jasmine'],
  
       files: [
            'js/angular.js',
            'js/angular-mocks.js',
            'app.js',
            'test/**/*Spec.js'
          ],
          exclude: [
          ],
  
          preprocessors: {
          },
          reporters: ['progress'],
          port: 9876,
  
          colors: true,
  
      config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
          logLevel: config.LOG_INFO,
  
          autoWatch: false,
  
  
          browsers: ['Firefox'],
  
          singleRun: false 
        });
      };
  </code></pre>
  
  <blockquote>
    <p>Here is my <strong>mySpec.js</strong> where test code is written</p>
  </blockquote>
  
  <pre><code>describe('myApp', function() {
  
      beforeEach(module('myApp'));
  
      describe('HelloWorldController', function() {
  
          var scope,HelloWorldController;
  
          beforeEach(inject(function ($rootScope, $controller) {
              scope = $rootScope.$new();
              HelloWorldController = $controller('HelloWorldController', {
                  $scope: scope
              });
          }));
  
          it('should assign message to hello world', function () {
              expect(scope.greeting).toEqual('Hello World!');
          });
      });
  });
  </code></pre>
  
  <blockquote>
    <p>And this is my <strong>app.js</strong> where controller is defined.</p>
  </blockquote>
  
  <pre><code>var myApp = angular.module('myApp',[]);
  myApp.controller('HelloWorldController', ['$scope', function($scope) {
      $scope.greeting = 'Hello World!';
  }]);
  </code></pre>
  
  <p>The error which I get is, </p>
  
  <blockquote>
    <p>TypeError: scope is undefined in**
    /home/abc/WebstormProjects/test1/test/basic/mySpec.js (line 17)</p>
  </blockquote>
  
  <p>I don't have any idea of where I am making mistake. Please guide me toward this issue. </p>
  
  <p>Thanks in advance.</p>