无法在模拟测试中注入角度控制器

时间:2016-06-10 22:36:18

标签: angularjs unit-testing mocha

我无法在Mocha测试文件中注入我的控制器,它会一直显示此错误:

error here

我跟着the documentation here并尝试了其他方法,这是测试文件中的代码:

var assert = chai.assert;
var expect = chai.expect;
var should = chai.should();

describe('Suplements Module', function(){
    beforeEach(angular.mock.module('atari-app'));
    beforeEach(inject(function ($rootScope, $controller) {
        scope = $rootScope.$new();
        controller = $controller('TestController', {
            '$scope': scope
        });
    }));

    describe('List supplements',function(){
        it('should list all supplements', function(){ });
    });
});

这是我的应用和控制器:

angular
    .module('atari-app', [
      'ui.router',
      'ui.utils',
      'oc.lazyLoad',
      'ngResource',
      'ngSanitize',
      'ui.bootstrap',
      'ui.select',
      'authentication-app',
      'angular-ladda',
      'ngAnimate',
      'toastr'
    ]);

  angular.module('atari-app')
    .controller('TestController', ['$scope',
      function ($scope) {
        $scope.testudo = 1;
      }
    ]);

我的mocha版本是2.5.3,角度是1.4.6

0 个答案:

没有答案
相关问题