【发布时间】:2013-07-11 04:00:15
【问题描述】:
我正在尝试使用 jasmine 进行一些基本测试。我使用一个外部库,我打算做的是监视/模拟库对象 (d3) 上的方法调用,并确保在 d3 上调用适当的方法。
var d3Spy = jasmine.createSpyObj('d3', ['select']);
spyOn(window, 'd3').andReturn(d3Spy);
expect(d3Spy.select).toHaveBeenCalled();
当在对象上调用“选择”时,我收到此错误。
TypeError: Object function () {
spyObj.wasCalled = true;
spyObj.callCount++;
var args = jasmine.util.argsToArray(arguments);
spyObj.mostRecentCall.object = this;
spyObj.mostRecentCall.args = args;
spyObj.argsForCall.push(args);
spyObj.calls.push({object: this, args: args});
return spyObj.plan.apply(this, arguments);
} has no method 'select'
我做错了什么?
【问题讨论】: