Yeoman をインストールして、最初のプロジェクトを作成しました。Yoによって作成されたデフォルトのangularプロジェクトのユニットテストに頭を悩ませようとしています。「grunt server」を呼び出すとプロジェクトは正常に実行されますが、単体テスト「grunt test:unit」を実行すると、「Argument 'MainCtrl' is not a function, got undefined」というエラーが表示されます。
このテストを適切に実行するには何が欠けていますか?
再度、感謝します
-- コントローラー
'use strict';
angular.module('myApp')
.controller('MainCtrl', function ($scope) {
$scope.awesomeThings = [
'HTML5 Boilerplate',
'AngularJS',
'Karma',
'mytest'
];
});
-- テストまで
'use strict';
describe('Controller: MainCtrl', function () {
// load the controller's module
beforeEach(module('myApp'));
var MainCtrl,
scope;
// Initialize the controller and a mock scope
beforeEach(inject(function ($controller, $rootScope) {
scope = $rootScope.$new();
MainCtrl = $controller('MainCtrl', {
$scope: scope
});
}));
it('should attach a list of awesomeThings to the scope', function () {
expect(scope.awesomeThings.length).toBe(4);
});
});