我有一個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_)。 –