I'm trying to unit test filter which has dependency on another service. I've read many answers regarding this problem but nothing solved mine. I use karma/Jasmine
the conf as follow
// Karma configuration
// Generated on Thu Nov 26 2015 07:47:24 GMT+0100 (Västeuropa, normaltid)
module.exports = function(config) {
config.set({
// base path that will be used to resolve all patterns (eg. files, exclude)
// frameworks to use
// available frameworks: http://ift.tt/1ft83uu
frameworks: ['jasmine'
],
// list of files / patterns to load in the browser
files: [
'lib/angular.min.js',
'lib/angular-mocks.js',
'test.js',
'app/js/services/*.js',
'app/js/filters/*.js'
],
// list of files to exclude
exclude: [
],
// preprocess matching files before serving them to the browser
// available preprocessors: http://ift.tt/1laYCcY preprocessor
preprocessors: {
},
my application as follow
// filter
var app=angular.module('app.filter',[]);
app.filter("filterName",['serviceName',function(ServiceName){
return function(input1,input2)
{
//some code
}]);
// service
var app=angular.module('app.service',[]);
app.service("serviceName", [$log,$windows,$route',function($log,$windows,$route){
//some functions
}]);
the test
describe('test filter with services dependencies',function()
{
beforeEach(module('app.service'));
beforeEach(module('app.filter'));
var FilterNAMe, ServiceNAMe ;
beforeEach(inject(function(_ServiceNAMe _,_FilterNAMe_) // i get error here
{
FilterNAMe = _FilterNAMe_;
ServiceNAMe= _ServiceNAMe_;
}));
it('',function()
{
//some test;
});
});
and I get the following error
error:[$injector:unpr] http://ift.tt/1YKtgrZ$injector/unpr?=%24serviceNameProvider
Error: Declaration location at windows.inject.angular.mock.inject
Aucun commentaire:
Enregistrer un commentaire