Is there some way I can find all active spies in sinon.js? I'd like to be able to do something like this:
afterEach ->
sinon.restoreAllSpies()
it "should not create a new MyClass", ->
spy = sinon.spy(window, 'MyClass')
expect(spy).not.toHaveBeenCalled()
Currently, I need to laboriously (and error-pronedly!) do this:
it "should not create a new MyClass", ->
spy = sinon.spy(window, 'MyClass')
expect(spy).not.toHaveBeenCalled()
window.MyClass.restore()
Any ideas?
I dont think so, cause all it does is to replace the function with a spy, it dont save all spies internally. So ether you store all spies in an array and reset them on afterEach, or just create/override new spies on beforeEach.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With