Sinon JS “Attempted to wrap ajax which is already wrapped”

前端 未结 2 889
挽巷
挽巷 2021-01-31 13:23

I got the above error message when I ran my test. Below is my code (I\'m using Backbone JS and Jasmine for testing). Does anyone know why this happens?

$(functio         


        
2条回答
  •  长发绾君心
    2021-01-31 14:16

    What you need in the very beginning is:

      before ->
        sandbox = sinon.sandbox.create()
    
      afterEach ->
        sandbox.restore()
    

    Then call something like:

    windowSpy = sandbox.spy windowService, 'scroll'
    
    • Please notice that I use coffee script.

提交回复
热议问题