beforeEach(async () => {
const sandbox = sinon.sandbox.create()
...
})
test('/add', () => {
// how can I use sandbox here?
})
我需要的是类似t.context
的ava
答案 0 :(得分:8)
只需声明沙箱,即可在beforeEach和test的范围内使用它:
let sandbox;
beforeEach(async () => {
sandbox = sinon.sandbox.create()
...
})
test('/add', () => {
// sandbox available for use
})