2017-09-14 43 views
0

我正在錯誤:柴+興農錯誤:方法已包裹

  • 類型錯誤:嘗試包裹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

回答

0

是唯一的地方,你是ajax存根?如果沒有,你需要確保你在每次測試之後恢復它,然後再嘗試再次存根

0

你爲什麼在stubbing和spying jQuery.ajax?刪除該行:sinon.stub(jQuery, 'ajax');