sinon.replace vs sinon.stub just to replace return value?
问题 When using sinon I just want to replace my function's return value and don't need other infos like how many time it was called. Which one of them is better? sinon.replace(Component.prototype, 'getValue', () => 123); const myStub = sinon.stub(Component.prototype, 'getValue'); myStub.return(123); 回答1: I rarely see sinon.replace being used in many projects. The advantage of using stub is you can modify the return value many times for example. let getValueStub; before(function() { getValueStub =