我有一个angularjs工厂,我注射了下划线和应用程序工作正常,但是当我尝试写茉莉花测试用例时,我得到一个错误下划线提供程序未找到 我有我的工厂像供应商找不到下划线
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) {
}
它给错误 错误:[$注射器:unpr]未知提供商:underscoreProvider < - 强调
您的下划线服务在哪里定义?我假定它不在一个单独的模块中,因为你没有列出任何依赖关系...... –
另外,在你的测试中使用inject()函数注入它们时,你的服务名应该被下划线包围(例如:_underscore_,_example_)。 –