reactjs - Attempting to test a React component with jasmine-react -
this question similar one of solutions question.
i'm using example similar real problem nicely distilled.
the following test produces result:
warning: comp.type deprecated. use comp directly access class. error: expected spy, 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 i'm doing wrong?
jasminereact's syntax method expectations different way you're using it. try this:
expect(jasminereact.classprototype(comp).plop).tohavebeencalled();
additionally, if you're running expectation against state, need use instance render
returns, rather class:
var comp = jasminereact.render(<comp />); expect(comp.state.something).tobe('else');
Comments
Post a Comment