业力 +茉莉 +Angular "Argument is not a function"

Karma +Jasmine +Angular "Argument is not a function"

我需要测试 Angular 控制器,但我看到一个错误: "Argument 'MainCtrl' is not a function, got undefined".

谁能帮帮我,我不知道...

 // file karma conf.js

     files: [
                'bower_components/angularjs/angular.js',
                'bower_components/angular-mocks/angular-mocks.js',

                'app.js',
                'controllers/*.js',
                'directives/*.js',
                'services/*.js',
                'controllers/controllersSpec.js',
        ],
    // app.js 

       var app = angular.module('app', []);

    // controller
    angular.module('app').controller('MainCtrl', ['$scope',
      function ($scope) {

        $scope.thing = 1;

     }]);
// controllersSpec.js

describe('MainCtrl', function() {
var controller, scope;

beforeEach(module('app'));

beforeEach(inject(function($controller, $rootScope) {
    scope = $rootScope.$new();
    controller = $controller('MainCtrl', {
        $scope: scope
    });
}));

it('should have scope to be defined', function() {
    expect(scope).toBeDefined();
});

});

谁能帮帮我,我不知道

看起来 MainCtrl 定义的文件尚未加载。检查此文件是否包含在 karma.conf.js.

除此之外,您的测试有效:http://jsbin.com/miroqomiyo/edit?html,js,output