虽然这里有一个相同的问题,但我找不到问题的答案,所以我的问题是:
我正在使用mocha和chai测试我的node js应用程序.我正在使用sinion来包装我的函数.
describe('App Functions', function(){
let mockObj = sinon.stub(testApp, 'getObj', (dbUrl) => {
//some stuff
});
it('get results',function(done) {
testApp.someFun
});
}
describe('App Errors', function(){
let mockObj = sinon.stub(testApp, 'getObj', (dbUrl) => {
//some stuff
});
it('throws errors',function(done) {
testApp.someFun
});
}
当我try 运行这个测试时,它会给我错误
Attempted to wrap getObj which is already wrapped
我也试着把
beforeEach(function () {
sandbox = sinon.sandbox.create();
});
afterEach(function () {
sandbox.restore();
});
在每一次描述中,都给了我同样的错误.