相关疑难解决方法(0)

轻松清理sinon存根

有没有办法轻松重置所有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)

javascript testing mocha.js stubbing sinon

126
推荐指数
6
解决办法
7万
查看次数

标签 统计

javascript ×1

mocha.js ×1

sinon ×1

stubbing ×1

testing ×1