0
我是angularJS和单元测试的新手,通常使用Karma/Jasmine。ReferenceError:无法在AngularJS中找到变量:xxxService,Karma
我正在尝试将单元测试添加到已存在的应用程序中。其中服务如下所示:
angular.module('fundMetadata').factory('fundMetadataService', [
'symedUIGridService',
'symEdService',
function(symedUIGridService, symEdService) {
var $scope;
function setCtrl(controller, scope) {
ctrl = controller;
$scope = scope;
}
function defaultGridOptions(columns, data) {
return (symedUIGridService.defaultGridOptionsGenerator(
$scope, ctrl))(columns, data);
}
function equityOptions() {
var options = defaultGridOptions(ctrl.fundMetadataResponse.equityColumns,
ctrl.fundMetadataResponse.equityRecords);
options.onRegisterApi = undefined;
return options;
}
return {
equityOptions: equityOptions,
setCtrl: setCtrl
}
}
]);
然后因果报应/茉莉以下测试:
PhantomJS 2.1.1 (Windows 7 0.0.0) fundMetadata should have the functions FAILED
[email protected]:/Users/rvendiola/proj/SymbologyEditor/Website/bower_components/angular/angular.js:321:24
[email protected]:/Users/rvendiola/proj/SymbologyEditor/Website/bower_components/angular/angular.js:4508:12
[email protected]:/Users/rvendiola/proj/SymbologyEditor/Website/bower_components/angular/angular.js:4430:30
[email protected]:/Users/rvendiola/proj/SymbologyEditor/Website/bower_components/angular-mocks/angular-mocks.js:2922:60
[email protected]:/Users/rvendiola/proj/SymbologyEditor/Website/bower_components/angular-mocks/angular-mocks.js:2902:46
C:/Users/rvendiola/proj/SymbologyEditor/Website/t/fundMetadataService.js:7:15
C:/Users/rvendiola/proj/SymbologyEditor/Website/bower_components/angular/angular.js:4548:53
ReferenceError: Can't find variable: fundMetadataService in C:/Users/rvendiola/proj/SymbologyEditor/Website/t/fundMetadataService.js (line 13)
C:/Users/rvendiola/proj/SymbologyEditor/Website/t/fundMetadataService.js:13:52
我做了一个简单的测试,测试一个app.js并工作正常,所以我认为我的安装很好。
有什么想法?
谢谢,但它仍然失败,相同的错误:的ReferenceError:找不到变量:fundMetadataService –
@BethuelVendiola:你是否设法解决这个问题? –