gpt4 book ai didi

javascript - AngularJS tdd 与 Jasmine 错误 : Cannot read property '$injector' of undefined

转载 作者:行者123 更新时间:2023-11-28 08:25:07 25 4
gpt4 key购买 nike

我有这些类型错误:- 无法读取未定义的属性“$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>

Jasmine 脚本:

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);
});

});

});

最佳答案

我遇到了同样的问题,使用非缩小的 Angular 和 Angular 模拟 1.3.0 为我解决了这个问题。

关于javascript - AngularJS tdd 与 Jasmine 错误 : Cannot read property '$injector' of undefined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22531053/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com