We use spyOn(this,"_new")
to track a function call in jasmine. I need to check the children method call in jasmine. My code sample is given below,
Sample code:
function perform(option) {
this.answer=this.perform._sum(option.a+option.b);
console.log(this.answer);
}
My question is how to check the this.perform.sum(option.a+option.b)
has been called with spyOn()
in jasmine JavaScript?
I have tried the below way, but it was not worked as much I expected?
it("If we pass arguments to the perform method, ensuring that the sum method has been called or not", function(done) {
spyOn(this,"perform._sum");
var option={a:10,b:6};
this.perform(option);
expect(this.perform._sum).toHaveBeenCalledWith(option.a,option.b);
done();
});
But above code has not worked. And also, I had posted an issue regarding this npm-jasmine:Issues. The Question details are given below:
how to check children method has been called in jasmine test cases
Can anybody tell me, how to check the children method call in jasmine using spyOn()
?
this
usage - do you have the test in the same file as the code under test?