gpt4 book ai didi

javascript - Angular,Jasmine 模拟整个模块依赖项 ,"is not available!"错误

转载 作者:行者123 更新时间:2023-11-29 10:43:39 25 4
gpt4 key购买 nike

在我的模块中我有一些依赖:

var app = angular.module('action', ['xeditable']);

Angular-xeditable 是一组 AngularJS 指令,可让您创建可编辑元素。更多:http://vitalets.github.io/angular-xeditable/

不结束我的 Jasmine 测试我想模拟所有这个模块。我是这样尝试的:

var mocks;
beforeEach(function() {
mocks = jasmine.createSpyObj("mocks", ["xeditable"]);

module("action", function($provide){
$provide.value('xeditable', mocks.xeditable)
});
});

但我仍然得到:

Error: [$injector:nomod] Module 'xeditable' is not available! 

我知道有很多关于它的问题,但不知道如何处理,非常请帮助:)

最佳答案

我解决了它,只是在加载模块之前添加了另一个 beforeEach,就像这样:

beforeEach(function () {
//mock the xeditable lib:
angular.module("xeditable", []);
});

beforeEach(function() {
module("action");
});

关于javascript - Angular,Jasmine 模拟整个模块依赖项 ,"is not available!"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23933428/

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