Sinon error Attempted to wrap function which is already wrapped

前端 未结 9 643
滥情空心
滥情空心 2020-12-24 04:01

Though there is a same question here but I could not find answer to my problem so here goes my question:

I am testing my node js app using mocha and chai. I am usin

9条回答
  •  死守一世寂寞
    2020-12-24 04:44

    For cases where you need to restore all the methods of one object, you can use the sinon.restore(obj).

    Example:

    before(() => {
        userRepositoryMock = sinon.stub(userRepository);
    });
    
    after(() => {
        sinon.restore(userRepository);
    });
    

提交回复
热议问题