我试图创建一个简单的单元测试来访问名为LimboExpenseService
的工厂。
angular.module( 'Trackee').factory( 'LimboExpenseService', require( './services/LimboExpenseService'))
我的测试看起来像:
describe('LimboService', function() {
var Limbo;
beforeEach(module('Trackee'));
it('should have a LimboExpenseService ', inject(['LimboExpenseService', function(LimboExpenseService) {
expect(LimboExpenseService).toBeUndefined();
}]));
});
问题是,我似乎无法通过inject()
方法获取该项目。
我在这里缺少什么?
答案 0 :(得分:0)
尝试在inject
块内调用beforeEach
函数。这应该有用。
以下是:
describe('LimboExpenseService', function() {
var LimboExpenseService;
beforeEach(module('Trackee'));
beforeEach(inject(function(_LimboExpenseService_){
LimboExpenseService = _LimboExpenseService_;
}))
it('should have a LimboExpenseService ',function(){
expect(LimboExpenseService).toBeDefined();
});
});