我正在使用jasmine进行单元测试,在我的情况下,模块有一些第三方和一些自定义依赖项,我已经尝试过某种方式来模拟这些依赖项,但它对我没有用。
我的代码示例
Module.js
var myApp = angular.module('mpapp', ['customservice', "xeditable",'ui.bootstrap', 'ngSanitize']);
testmodule.js
angular.mock.module('customservice', []);
angular.mock.module('xeditable', []);
angular.mock.module('ui.bootstrap', []);
angular.mock.module('ngSanitize', []);
module('myapp');
---这里需要一些测试用例。
就像我试图模仿但它得到错误
" [$ injector:modulerr] http://errors.angularjs.org/1.5.9/ $ injector / modulerr?p0 = eai.pages& p1 =错误%3A%20%5B%24injector%3Amodulerr%5D%20http%3A%2F %2Ferrors.angularjs.org%2F1.5.9%2F%24injector%2Fmodulerr%3Fp0%3Dui.bootstrap%26P1%3DError%253A%2520%255B%2524injector%253Anomod%255D%2520http%253A%252F%252Ferrors.angularjs.org %252F1.5.9%252F%2524injector%252Fnomod%253Fp0%253Dui.bootstrap%250A%2520%2520%2520at%2520Anonymous%2520function%2520(文件%253A%252F%252F%252Fd%253A%252Fvinoth%252Feai%252Fmetlife.eai -newlayout%252Fmetlife.eai%252Fangular%252Flib%252Fangular.min.js%253A25%253A229)%250A%2520%2520%2520at%2520B%2520(文件%253A%252F%252F%252Fd%253A"
所以,请给我任何解决此问题的建议。感谢。
答案 0 :(得分:0)
我是这样做的
beforeEach(
function(){
module('myModule');
inject(function(_$compile_, _$rootScope_,_myService_){
$compile = _$compile_;
$rootScope = _$rootScope_;
myService= _myService_;
//test code here
}
);