【发布时间】:2013-12-03 11:33:03
【问题描述】:
我有以下测试套件:
describe('rendering Bundle View', function () {
beforeEach(function () {
this.view = new Backbone.View();
this.renderStub = Sinon.stub(this.view, 'render', function () {
this.el = document.createElement('div');
return this;
});
this.view.render();
});
it('should have called render once', function () {
console.info('RENDERRRR' + (typeof this.renderStub));
expect(this.renderStub.calledOnce).toBe(true); // this passes
expect(this.renderStub).toHaveBeenCalled(); // this fails
});
});
为什么第一个期望语句通过但第二个失败?第二个给出错误消息:expected Spy but got Function 即使 Sinon 存根实现了 spy API 所以它应该返回一个 spy??
【问题讨论】:
-
您应该实际提交您的问题的答案或将其删除,以免想要提供帮助的人来这里。
标签: debugging jasmine sinon spy stubs