0

Git Hub のサンプル コードは次のとおりです。

https://github.com/Mellon/KarmaWithRequirejs.git

「grunt test」を実行すると、このエラーが発生します。

Error: [ng:areq] Argument 'MyController' is not a function, got undefined
http://errors.angularjs.org/1.3.14/ng/areq?p0=MyController&p1=not%20a%20function%2C%20got%20undefined
    at assertArg (/Users/csun/FrontEnd/KarmaWithRequirejs/node_modules/angular/angular.js:1580)
    at assertArgFn (/Users/csun/FrontEnd/KarmaWithRequirejs/node_modules/angular/angular.js:1591)
    at /Users/csun/FrontEnd/KarmaWithRequirejs/node_modules/angular/angular.js:8431
    at /Users/csun/FrontEnd/KarmaWithRequirejs/test/myControllerSpec.js:13
    at invoke (/Users/csun/FrontEnd/KarmaWithRequirejs/node_modules/angular/angular.js:4185)
    at workFn (/Users/csun/FrontEnd/KarmaWithRequirejs/node_modules/angular-mocks/angular-mocks.js:2364)
undefined
4

1 に答える 1

0

define(['expect'], function () {
    'use strict';
    describe('MyController', function () {
        var controllerContructor, scope, controller;
        before(function () {//change before to beforeEach, it works.
            module('app');
            inject(function ($controller, $rootScope) {
                controllerContructor = $controller;
                scope = $rootScope.$new();
                controller = controllerContructor('MyController', {$scope: scope});
            });
        });

        it('shoule be loaded.', function () {
            expect(controller).to.be.an('object');
        });
    });
});

于 2015-02-28T18:10:37.133 に答える