【发布时间】:2017-09-14 20:52:57
【问题描述】:
我收到错误:
- TypeError: 试图包装已经包装好的 ajax
-
错误:原始堆栈跟踪 chai.should();
describe("Test API", function() { it('executes a GET request for ISPs', function() { var mySpy = sinon.spy(jQuery, "ajax"); sinon.stub(jQuery, 'ajax'); mySpy.should.have.been.calledWithMatch({ url: 'http://data-api.measurementlab.net/locations/nausdcwashington/clients' }); }); after(function() { jQuery.ajax.restore(); }); });
我遇到了类似的帖子并添加了after 块。仍然出现同样的错误:Sinon.js- Trying to spy on console.log but it is already wrapped
【问题讨论】:
标签: javascript unit-testing sinon sinon-chai