'Testcase JS , need to stub api call twice but not getting expected result

Using sinon stub oncall feature

const apicallback = sinon.stub();
apicallback.onCall(0).returns(1);
apicallback.onCall(1).returns(2);

The sequence of operation is first getAPIcall-> get result in react component0-> simulate submitbuton click -> save result -> second getapicall , however getting error done called multiple times and no fallback defined for secondgetapicall, what could be going wrong ?using enzyme,mocha



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source