mercredi 22 avril 2015

Verifying function call and inspecting arguments using sinon spies

I would like to verify that bar() is called inside foo() from my unit test.

I figured that Sinon spies might be suitable, but I don't know how to use them.

Is there any way to check that the method is called? Perhaps even extracting the arguments used in the bar() call?

var spy = sinon.spy(foo);

function foo(){
    bar(1,2,3);
}

function bar(){ }

foo();

// what to do with the spy?

http://ift.tt/1aS62vC

Aucun commentaire:

Enregistrer un commentaire