我的测试设置有问题。当一个文件中的所有内容都可以工作时,它不会在代码分散在多个文件中时使用。AngularJS - 使用模块approuch进行测试
当代码传播按下面,我得到一个错误Error: [$injector:unpr] Unknown provider: twoPlusTwoFilterProvider <- twoPlusTwoFilter
// js/index.js
angular.module('app', []);
// js/twoPlusTwoFilter.js
angular.module('app').filter('hex', function hex(){
return function(input){
return input+input;
}
});
// here is my test
describe('check sanity', function() {
beforeEach(module('app'));
it('should return 4', inject(function(hexFilter) {
expect(hexFilter(2)).toEqual(4);
}));
});
仅供参考,我包括善缘的conf角嘲笑。任何建议非常感谢。
您是否加载了karma.conf.js中的所有文件? – marneborn 2014-08-28 16:40:44
什么是'twoPlusTwoFilter'? – PSL 2014-08-28 16:42:44
@marneborn - 是的,所有图书馆,来源和测试.. – Iladarsda 2014-08-28 16:43:30