title: Angular Karma test not running properly, gives error "Argument 'fn' is not a function, got undefined"
body: <p>I'm trying to add unit tests to an angular controller using karma but I've run into an issue and I need some help. I've found similar questions asked here but none have led me to an answer. I've tried changing the order of the "files" array in the karma.conf.js thinking perhaps they weren't being loaded properly but that hasn't yielded any results. When I run 'karma start karma.conf.js' I get the error</p>
  
  <p><strong>console error from karma</strong></p>
  
  <pre><code>Error: [$injector:modulerr] Failed to instantiate module undefined due to:
  Error: [ng:areq] Argument 'fn' is not a function, got undefined
  at assetArg (D:/xxxx/bower_components/angular/angular.js:1580
  ...
  ...
  ...  (long callstack within angular.js and angular-mocks.js)
  ...
  ...
  at workFn (D:/xxxx/bower_components/angular-mocks/angular-mocks.js:2172
  </code></pre>
  
  <p>I'm only using one test file for now, and it's very basic. The module name is correct and the 'myApp.views.view1` file is being served by the karma server, the "debug" level karma logging confirms it</p>
  
  <p><strong>view1_test.js</strong></p>
  
  <pre><code>'use strict';
  
  describe('myApp.views.view1 module', function() {
  
    beforeEach(module('myApp.views.view1',[]));
  
    describe('view1 controller', function(){
  
      it('should exist....', inject(function($controller) {
        //spec body
        var view1Ctrl = $controller('View1Ctrl');
        expect(view1Ctrl).toBeDefined();
      }));
  
    });
  });
  </code></pre>
  
  <p>And heres' the view controller it's testing</p>
  
  <p><strong>view1.js</strong></p>
  
  <pre><code>'use strict';
  
  angular.module('myApp.views.view1', ['ngRoute'])
  
  .config(['$routeProvider', function($routeProvider) {
    $routeProvider.when('/view1', {
      templateUrl: 'src/views/view1/view1.html',
      controller: 'View1Ctrl'
    });
  }])
  .controller('View1Ctrl', ['$scope','$anchorScroll',function($scope,$anchorScroll) {
      //scroll to top of page
      $anchorScroll();
  
      $scope.testVar = "it works, congrats!";
  
  
  }]);
  </code></pre>
  
  <p><strong>directory structure</strong></p>
  
  <pre><code>/
  .bowerrc
  .gitignore
  bower.json
  package.json
  karma.conf.js
  /sass_styles
      base.scss
  /app
      index.html
      /src
           app.js
           /bower_components
           /directives
               /example
                   directive.js
                   template.html
           /views
               /view1
                   view1.html
                   view1.js
                   view1_test.js
           /styles
               base.css
  </code></pre>
  
  <p>This is my karma.conf.js file. I'm using PhantomJS as the browser and html2js preprocessor to include directive .html templates that use 'templateURL'</p>
  
  <p><strong>karma.conf.js</strong></p>
  
  <pre><code>module.exports = function(config){
      config.set({
  
          basePath : './app/',
  
          preprocessors: {
              'src/directives/**/*.html': ['ng-html2js']
          },
  
          files : [
              'src/bower_components/angular/angular.js',
              'src/bower_components/angular-route/angular-route.js',
              'src/bower_components/angular-mocks/angular-mocks.js',
              'src/directives/**/*.js',
              'src/views/**/*.js',
              //directive templates
              'app/src/directives/**/**.html'
          ],
  
          autoWatch : true,
  
          // level of logging
          // possible values: LOG_DISABLE || LOG_ERROR || LOG_WARN || LOG_INFO || LOG_DEBUG
          logLevel: config.LOG_DEBUG,
  
          frameworks: ['jasmine'],
  
          browsers : ['PhantomJS'],
  
          plugins : [
                  'karma-chrome-launcher',
                  'karma-firefox-launcher',
                  'karma-phantomjs-launcher',
                  'karma-jasmine',
                  'karma-junit-reporter',
                  'karma-ng-html2js-preprocessor'
              ],
  
          junitReporter : {
            outputFile: '../test_out/unit.xml',
            suite: 'unit'
          },
  
          ngHtml2JsPreprocessor: {
              // strip app from the file path
              stripPrefix: 'app/',
              stripSufix: '.ext',
              // prepend this to the 
              prependPrefix: 'served/',
  
              // setting this option will create only a single module that contains templates 
              // from all the files, so you can load them all with module('foo') 
              moduleName: 'templates'
          }
  
  
    });
  };
  </code></pre>
  
  <p>Apologies for copy pasting a ton of stuff but this is an involved process and I want to make sure I'm not missing one small part. So what am I doing wrong here that's causing this error?</p>