在我的模块中,我有一些依赖项:
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/