我使用jasmine-node进行单元测试。我做了下面的代码来模拟Date.now()
spyOn(Date, 'now').andReturn(1387636363717); //always return a fixed time
然后我尝试运行jasmine-node spec/,但它停止工作,没有输出。我想不出是什么原因。
我正在尝试学习Ext和用Jasmine框架进行单元测试。我编写了这个方法,我想测试decode方法是否被调用具有一定的值,但是我一直得到标题中提到的错误。我在这里做错什么了?
方法:
onSuccess: function (response) {
var text = Ext.decode(response.responseText);
this.someGrid.store.loadRawData(text);
}
茉莉花规格:
it('Function will call decode method', function () {
var resp
我正在为以下代码编写jasmine单元测试:
this.confirmationService.confirm({
message: 'Are you sure that you want to delete?',
accept: () => {
//some code to test
}
});
如何在对话框中假装单击Yes来测试accept()函数中的代码?
我研究了关于在Jasmine中监视函数的其他问题,但我的疑问没有得到回答。我打算在我的src脚本中使用andCallThrough跟踪我的原始函数。这就是我所拥有的:
describe("My Test to spy :", function() {
var mySpy = jasmine.createSpy(window, "login");
beforeEach(function(){
myS
我目前正在为地理定位API编写单元测试。
我的角度组件看起来如下:
export class HeaderComponent {
public lat: number = 56.713;
public lng: number = 21.1644;
public message: string;
public messageType: string;
public locationSuccess(data: any) {
console.log(data);
if (data) {
if (data.coords) {
this.
我的组件是在ngOnInit期间使用角元服务来更新元标记。我正在使用我的RegionService获得一个应用程序id,并通过一个模板文本使用Meta的updateTag方法来设置它。但是,我的单元测试在获取模板文本中的RegionService设置的值时遇到了问题。测试返回以下错误:
Expected spy Meta.updateTag to have been called with:
[ Object({ name: 'apple-itunes-app', content: 'app-id=0123456789' }) ]
but actual ca