简单茉莉花测试注入$日志服务 [英] Inject $log service on simple Jasmine test
本文介绍了简单茉莉花测试注入$日志服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是的,我完全新的角度和茉莉,我无法弄清楚如何注入模拟$日志我的测试。这是测试
Yes, I'm completely new to Angular and Jasmine, and I can't figure out how to inject a mock $log for my test. This is the test:
(function () {
'use strict';
describe('basic test', function(){
it('should just work', function(){
var $log;
beforeEach(inject(function(_$log_){
$log = _$log_;
}));
$log.info('it worked!');
expect($log.info.logs).toContain(['it worked!']);
});
});
}())
这失败与错误的注入行:
This fails on the inject line with an error:
TypeError: Cannot set property 'typeName' of undefined
我是什么失踪?
推荐答案
这个怎么样:
describe('basic test', function(){
var log;
beforeEach(inject(function(_$log_){
log = _$log_;
}));
it('should just work', function(){
log.info('it worked!');
expect(log.info.logs).toContain(['it worked!']);
});
});
这篇关于简单茉莉花测试注入$日志服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文