【发布时间】:2015-12-21 21:52:17
【问题描述】:
我有一个 angularjs 工厂,我正在向其中注入下划线,并且应用程序工作正常,但是当我尝试在其上编写 jasmine 测试用例时,我收到一个错误,找不到下划线提供程序 我有我的工厂
angular.module("sample")
.factory("example", example);
example.$inject = ["$document", "$compile", "$rootScope", "$timeout", "$q", "underscore"];
function example($document, $compile, $rootScope, $timeout, $q, _) {
}
我的模块定义为
(function(){
angular.module(samlple,[]);
})();
我的测试用例是
beforeEach(module('sample'));
beforeEach(module('ionic'));
beforeEach(inject(function ($document, $compile, $rootScope, $timeout,underscore,example) {
}
给出错误 错误:[$injector:unpr] 未知提供者:underscoreProvider
【问题讨论】:
-
你的下划线服务是在哪里定义的?我假设它不在单独的模块中,因为您没有列出依赖项...
-
此外,在使用您的文件中的 inject() 函数注入服务名称时,您的服务名称应该用下划线括起来(例如:underscore、example)测试。
标签: angularjs ionic-framework angularjs-provider