How to mock a function inside another function (which I am testing) using sinon?
问题 let's say i have a function Func a() { //Do Something let c = b(); return c; } I want to test the function a and mock b() and in the mock want to assign c. Sinon.Stub(Test,"b").returns("DummyValue"); c should be assigned DummyValue. How can I do that? describe("a", () => { let a = a(); //mock b(); action = execute(a); expect(action).should.return.("DummyValue"); }) 回答1: When we have 2 functions in the same file and want to stub one of them and test the other. For example,: Test: tests.js let