我正在对节点应用程序进行测试。 sinon.mock返回一个空对象,很显然我无法测试嘲笑getAccounts.expects('getAccounts')。once();
我还发布了先前的问题sinonStub.called prints false, though I am calling the function,我尝试使用存根(stub)进行类似的测试
mockspec.js
it.only('should mock getAccounts and always return mock response',function(){
var mockgetAccounts=sinon.mock(devices);
devices.getAccounts(req1);
mockgetAccounts.expects('getAccounts').once();
mockgetAccounts.verify();
})
devices.js
function getAccounts(Id){
....
....
returns promise;
}