title: Uncaught Error: Mismatched anonymous define() module: function in karma and jasmine unit testing with requirejs
body: <p>I am trying to run unit test cases for my controllers, I have tried the following but getting the below error, please let me know to run this test successfully. Thanks in advance.</p>
  
  <p>spec.js:</p>
  
  <pre><code>describe('MainCtrl', function() {
    beforeEach(module('app-module'));
    var $controller;
    beforeEach(inject(function(_$controller_){ 
      $controller = _$controller_;
    }));
  
    describe('$scope.titleofapp', function() {
      var $scope, controller;
      beforeEach(function() {
        $scope = {};
        controller = $controller('MainCtrl', { $scope: $scope });
      });
  
      it('sets the title of app to "app-module" module', function() {
        $scope.titleofapp();
        expect($scope.title).toEqual('My Test App !');
      });
    });
  });
  </code></pre>
  
  <p>app.js:</p>
  
  <pre><code>define(['angular', './app-module'], function(angular, appModule) {
      'use strict';
      return appModule.controller('MainCtrl', ['$http', '$q', 'appService', '$stateParams', function($http, $q, $stateParams, appService){
          $scope.titleofapp = function(){
          $scope.title = 'My Test App !';}
     }]);  
  });
  </code></pre>
  
  <p>Below is my karma.conf.js file configuration:</p>
  
  <p>karma.conf.js:</p>
  
  <pre><code>module.exports = function(config) {
    config.set({
      basePath: '',
      frameworks: ['jasmine','requirejs'],
  
      files: [
              'node_modules/requirejs/require.js',
              'node_modules/karma-requirejs/lib/adapter.js',
              'node_modules/angular/angular.js',
              'node_modules/angular-mocks/angular-mocks.js',
             'public/app/app.js',
             'public/tests/spec.js'
           ],
  
      exclude: [
      ],
  
      plugins: [
              'karma-requirejs',
              'karma-chrome-launcher',
              'karma-jasmine'
            ],
      preprocessors: {
      },
      reporters: ['progress'],
  
      port: 9876,
      colors: true,
      logLevel: config.LOG_INFO,
      autoWatch: true,
      browsers: ['Chrome'],
       singleRun: false,
      concurrency: Infinity
    })
  }
  </code></pre>
  
  <p>I have configured requirejs like above and getting the below error now:
  Error:</p>
  
  <pre><code>    Uncaught Error: Mismatched anonymous define() module: function (angular, appModule) {
        'use strict';
      return appModule.controller('MainCtrl', ['$http', '$q', 'appService', '$stateParams', function($http, $q, $stateParams, appService){
          $scope.titleofapp = function(){
          $scope.title = 'My Test App !';}
  
        }]);
    }
    http://requirejs.org/docs/errors.html#mismatch
    at node_modules/requirejs/require.js:165
  </code></pre>