This question is very similar to one of the solutions to this question.
I'm using this as my example as its similar to my real problem but nicely distilled.
The following test produces this result:
Warning: Comp.type is deprecated. Use Comp directly to access the class.
Error: Expected a spy, but got undefined.
The test:
it("should call plop method on render", function(){
var Comp = React.createClass({
displayName: "Comp",
plop: function() {
console.log("plop");
},
render: function() {
this.plop();
return (<div></div>);
}
});
//spy on method
jasmineReact.spyOnClass(Comp, "plop");
jasmineReact.render(<Comp />);
expect(Comp.plop).toHaveBeenCalled();
})
Any idea what I'm doing wrong?