我正在继承一些代码,其中有两个测试仍然失败,不确定它们以前是否失败过,或者是因为我使用了不同版本的Jasmine(它们是在2.0之前编写的)。
在beforeEach中设置了这个spy,导致测试失败。
spyOn(datacontext, 'getImportLogForDate').and.callThrough();
在测试中,需要进行以下步骤:
controller.DepositDate = new Date();
controller.PerformActionThatCallsGetImportLogForDate();
expect(context.getImportLogForDate).toHaveBeenCalledWith('1', controller.DepositDate);
由于它们完全相同,因此产生的错误令人困惑
期望调用间谍函数 getImportLogForDate 时传入 [ '1', Date(Thu Dec 04 2014 13:00:51 GMT-0600 (Central Standard Time)) ] ,但实际调用为 [ '1', Date(Thu Dec 04 2014 13:00:51 GMT-0600 (Central Standard Time)) ]
我不能验证函数是否已使用日期进行调用吗?