有没有办法轻松重置所有sinon spys模拟和存根,将与mocha的beforeEach块干净地工作.
我看到沙盒是一个选项,但我不知道如何使用沙盒
beforeEach ->
sinon.stub some, 'method'
sinon.stub some, 'mother'
afterEach ->
# I want to avoid these lines
some.method.restore()
some.other.restore()
it 'should call a some method and not other', ->
some.method()
assert.called some.method
Run Code Online (Sandbox Code Playgroud)