I am getting error:
- TypeError: Attempted to wrap ajax which is already wrapped
Error: Stack Trace for original 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(); }); });
I came across similar posts and added the after
block. Still getting the same error: Sinon.js- Trying to spy on console.log but it is already wrapped
is that the only place you're stubbing ajax? If not, you need to make sure you restore it after each test before trying to stub it again