使用 sinon 时,我只想替换函数的返回值,不需要其他信息,例如调用了多少次。其中哪一个更好?
sinon.replace(Component.prototype, 'getValue', () => 123);
Run Code Online (Sandbox Code Playgroud)
const myStub = sinon.stub(Component.prototype, 'getValue');
myStub.return(123);
Run Code Online (Sandbox Code Playgroud)