单元测试 – 测试角度服务提供错误:无模块:ngResource
发布时间:2020-12-17 08:05:39 所属栏目:安全 来源:网络整理
导读:我有以下应用程序的yeoman-angular设置: angular.module('myApp',['ngResource','ui.bootstrap']) .config(['$routeProvider',function ($routeProvider) { $routeProvider ... }]); 和服务: angular.module('myApp') .factory('UserSvc',[function() { re
我有以下应用程序的yeoman-angular设置:
angular.module('myApp',['ngResource','ui.bootstrap']) .config(['$routeProvider',function ($routeProvider) { $routeProvider ... }]); 和服务: angular.module('myApp') .factory('UserSvc',[function() { return { name : '',topicOrder: 'lec_type',}; }]); 和以下测试: describe('Service: UserSvc',function () { beforeEach(module('mfApp')); var UserSvc; beforeEach(inject(function(_UserSvc_) { UserSvc = _UserSvc_; })); it('should do something',function () { expect(UserSvc.topicOrder).toEqual('lec_type'); }); }); 我尽力在测试中注入$资源(虽然srvice本身不是在ngResource上挂起),但是当我运行测试时,我收到这个错误 Error: No module: ngResource 如果我从模块本身删除依赖关系, angular.module('myApp',[]) 那么测试成功运行 我真的尝试过一切,但失败了
在testacular.conf.js / karma.conf.js中,你是否包含angular-resource.js;例如
files = [ JASMINE,JASMINE_ADAPTER,'app/vendor/angular/angular.js','app/vendor/angular/angular-*.js', (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |