mardi 18 octobre 2016

Stubbing function while sinon testing

I have an functions call in following order:

function firstOne() {
  secondOne();
}

function secondOne() {
  thirdOne(forthOne()).then(...);
}

function thirdOne() {...}

function fourthOne() {...}

Now, while testing firstOne()

thirdOne= new Promise(resolve => {
        someResolve = resolve
    });
forthStub = sinon.stub();
sandbox.stub(Api, 'thirdOne').withArgs(forthStub).returns(somePromise);    
firstOne();  

I am getting error

TypeError: Cannot read property 'then' of undefined

Any suggestion?

Aucun commentaire:

Enregistrer un commentaire