AngularJS tdd与Jasmine错误:无法读取属性' $ injector'未定义的

时间:2014-03-20 11:08:20

标签: javascript angularjs tdd jasmine inject

我有这些TypeError: - 无法阅读财产' $ injector'未定义的 - 无法阅读财产' $ modules'未定义的 - 无法调用方法' selPersonToChange'未定义的

jasmine html页面中包含的文件是独立的:

  <script type="text/javascript" src="lib/jasmine-2.0.0/jasmine.js"></script>
  <script type="text/javascript" src="lib/jasmine-2.0.0/jasmine-html.js"></script>
  <script type="text/javascript" src="lib/jasmine-2.0.0/boot.js"></script>

  <script src="../../angular.min.js"></script>
  <script src="../../angular-mocks.js"></script>
  <script type="text/javascript" src="../form-input/script.js"></script>

  <script type="text/javascript" src="../form-input/tdd.js"></script>

茉莉花剧本:

describe("myApp", function(){

    beforeEach(module("mymod"));

    describe("maincontroller", function(){

        var scope;
        var ctrl;
        beforeEach(inject(function($rootScope, $controller){
            scope = $rootScope.$new();
            ctrl = $controller("maincontroller", {$scope:scope});    
        }));

        it("select person", function(){
             a = scope.selPersonToChange();
             expect(a).toEqual(true);     
        });

    });

});

1 个答案:

答案 0 :(得分:0)

我遇到了同样的问题,使用非缩小角度和角度模拟1.3.0解决了它。