title: Getting this error "Error: beforeEach expects a function argument; received [object Object]" while testing angularjs using karma and jasmine
body: <p><a href="https://i.stack.imgur.com/LM341.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LM341.jpg" alt="enter image description here" /></a></p>
  <p>I am getting this error &quot;Error: beforeEach expects a function argument; received [object Object]&quot; while testing angularjs using karma and jasmine. I have tried in so many ways but couldn't get the solution. I have given below my spec code and karma conf js. For your information I do use requirejs in my application due to some dependencies</p>
  <pre class="lang-js prettyprint-override"><code>//Service Spec code :
  define([], function () {
    'use strict';
    describe('search Service spec', function () {
      var searchService;   
      beforeEach(angular.module('flightRouteApp', []));    
      describe('service methods', function () {
        it('should calculate the length of the element', inject(function (searchService) {
          expect(searchService).toBeDefined();
        }));
      });
    });
  });
  </code></pre>
  <pre class="lang-js prettyprint-override"><code>// Karma configuration
  // Generated on Sun Mar 05 2017 09:17:46 GMT+0100 (W. Europe Standard Time)
  /* global module */
  &quot;use strict&quot;;
  module.exports = function (config) {
  config.set({
    // base path that will be used to resolve all patterns (eg. files, exclude)
    basePath: '',
  
    // frameworks to use
    // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
    frameworks: ['jasmine','requirejs'],
  
    // list of files / patterns to load in the browser
    files: [
      {pattern:'node_modules/angular/angular.js',watched: true, included: true, served: true},
      {pattern:'node_modules/angular-mocks/angular-mocks.js',watched: true, included: true, served: true},
      {pattern:'app/js/flightRoute.js',watched: true, included: true, served: true},
      {pattern:'app/js/services/*.js',watched: true, included: true, served: true},
      {pattern:'app/js/**/*.js',watched: true, included: true, served: true},
      {pattern:'tests/test-main.js',watched: true, included: true, served: true},
      {pattern: 'tests/**/*.Spec.js',watched: true, included: true, served: true}
    ],
  
    // list of files to exclude
    exclude: [ ],
  
    // test results reporter to use
    // possible values: 'dots', 'progress'
    // available reporters: https://npmjs.org/browse/keyword/karma-reporter
    /*reporters: ['progress','coverage'],*/
    reporters: config.angularCli &amp;&amp; config.angularCli.codeCoverage
             ? ['progress', 'coverage-istanbul']
             : ['progress', 'kjhtml'],
    preprocessors: {
      'app/js/**/*.js': 'coverage'
    },
  
    // web server port
    port: 9876,
    coverageReporter: {includeAllSources: true, reporters:[{type: 'html', dir:'coverage/'}]},
  
    // enable / disable colors in the output (reporters and logs)
    colors: true,
    //vel of logging
    // possible values: config.LOG_DISABLE || config.LOG_ERROR || 
    config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
    logLevel: config.LOG_INFO,
  
    // enable / disable watching file and executing tests whenever any file changes
    autoWatch: false,
  
    // start these browsers
    // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
    browsers: ['Chrome'],
  
    // Continuous Integration mode
    // if true, Karma captures browsers, runs the tests and exits
    singleRun: false,
  
    // Concurrency level
    // how many browser should be started simultaneous
    concurrency: Infinity
    })
  }
  </code></pre>