I am facing issue in writing test case in filter. Here is my code
test.js describe('app', function() { beforeEach(angular.mock.module('app'));
var $filter; angular.mock.inject(function(_$filter_) { $filter = _$filter_; }); it('should convert hours to minute 1*60', function($filter) { var hours = $filter('hoursToMinutes')(1); expect(hours).toBe(60); });
}); filter.js app.filter('hoursToMinutes', function() { return function(hours) { return hours * 60; }; }); app.js var app = angular.module('app', [ 'ngAnimate', 'ui.bootstrap', 'ngCookies', 'ngSanitize', 'ngRoute', 'ui.router', 'base64', 'smart-table', 'dialogs.main', 'angularBootstrapNavTree', 'blockUI', 'angular-json-rpc', 'ngHandsontable', 'ui.bootstrap', 'filters.camelcase', 'ngVis', 'schemaForm', 'cfp.loadingBar', 'ngFileUpload', 'smart-table', 'angular-uuid', 'xeditable', 'ui.sortable', 'jp.ng-bs-animated-button', 'agGrid', 'angular-confirm', 'git-grid', 'filters.camelcase', 'angularMoment', 'ng.jsoneditor', 'long2know', 'blockUI', // 'ngIdle', 'chart.js', 'angular-growl', 'ui.toggle', 'angularFileUpload' ]); karma.conf.js files: [ '../../../bowercomponents/angular/angular.js', '../../../bowercomponents/angular-animate/angular-animate.js', '../../../bowercomponents/angular-mocks/angular-mocks.js', '../../../bowercomponents/angular-sanitize/angular-sanitize.js', '../../../bowercomponents/angular-bootstrap/ui-bootstrap.js', '../../../bowercomponents/angular-bootstrap/ui-bootstrap-tpls.js', '../../../bowercomponents/angular-cookies/angular-cookies.js', '../../../bowercomponents/angular-validation-match/src/angular-validation-match.js', '../../../bower_components/ng-sortable/dist/ng-sortable.js', '../app.js', '../filters.js', '../controllers/controllers.js', 'unit/*.js' ],
when running the karma its throwing me this error
forEach@C:/Sunguard%20Project/Unit%20Testing%20Sgas-UI/sgas-res-ui/sgas-res-ui/bowercomponents/angular/angular.js:410:24 loadModules@C:/Sunguard%20Project/Unit%20Testing%20Sgas-UI/sgas-res-ui/sgas-res-ui/bowercomponents/angular/angular.js:4917:12 createInjector@C:/Sunguard%20Project/Unit%20Testing%20Sgas-UI/sgas-res-ui/sgas-res-ui/bowercomponents/angular/angular.js:4839:30 WorkFn@C:/Sunguard%20Project/Unit%20Testing%20Sgas-UI/sgas-res-ui/sgas-res-ui/bowercomponents/angular-mocks/angular-mocks.js:3172:60 loaded@http://localhost:9876/context.js:162:17 C:/Sunguard%20Project/Unit%20Testing%20Sgas-UI/sgas-res-ui/sgas-res-ui/bower_components/angular/angular.js:4958:53
I am facing issue in writing test case in filter. Here is my code
test.js
describe('app', function() {
beforeEach(angular.mock.module('app'));
});
filter.js
app.filter('hoursToMinutes', function() {
return function(hours) {
return hours * 60;
};
});
app.js
var app = angular.module('app', [
'ngAnimate',
'ui.bootstrap',
'ngCookies',
'ngSanitize',
'ngRoute',
'ui.router',
'base64',
'smart-table',
'dialogs.main',
'angularBootstrapNavTree',
'blockUI',
'angular-json-rpc',
'ngHandsontable',
'ui.bootstrap',
'filters.camelcase',
'ngVis',
'schemaForm',
'cfp.loadingBar',
'ngFileUpload',
'smart-table',
'angular-uuid',
'xeditable',
'ui.sortable',
'jp.ng-bs-animated-button',
'agGrid',
'angular-confirm',
'git-grid',
'filters.camelcase',
'angularMoment',
'ng.jsoneditor',
'long2know',
'blockUI',
// 'ngIdle',
'chart.js',
'angular-growl',
'ui.toggle',
'angularFileUpload'
]);
karma.conf.js
files: [
'../../../bowercomponents/angular/angular.js',
'../../../bowercomponents/angular-animate/angular-animate.js',
'../../../bowercomponents/angular-mocks/angular-mocks.js',
'../../../bowercomponents/angular-sanitize/angular-sanitize.js',
'../../../bowercomponents/angular-bootstrap/ui-bootstrap.js',
'../../../bowercomponents/angular-bootstrap/ui-bootstrap-tpls.js',
'../../../bowercomponents/angular-cookies/angular-cookies.js',
'../../../bowercomponents/angular-validation-match/src/angular-validation-match.js',
'../../../bower_components/ng-sortable/dist/ng-sortable.js',
'../app.js',
'../filters.js',
'../controllers/controllers.js',
'unit/*.js'
],
when running the karma its throwing me this error
forEach@C:/Sunguard%20Project/Unit%20Testing%20Sgas-UI/sgas-res-ui/sgas-res-ui/bowercomponents/angular/angular.js:410:24
loadModules@C:/Sunguard%20Project/Unit%20Testing%20Sgas-UI/sgas-res-ui/sgas-res-ui/bowercomponents/angular/angular.js:4917:12
createInjector@C:/Sunguard%20Project/Unit%20Testing%20Sgas-UI/sgas-res-ui/sgas-res-ui/bowercomponents/angular/angular.js:4839:30
WorkFn@C:/Sunguard%20Project/Unit%20Testing%20Sgas-UI/sgas-res-ui/sgas-res-ui/bowercomponents/angular-mocks/angular-mocks.js:3172:60
loaded@http://localhost:9876/context.js:162:17
C:/Sunguard%20Project/Unit%20Testing%20Sgas-UI/sgas-res-ui/sgas-res-ui/bower_components/angular/angular.js:4958:53