unit testing - How can I access inline style using React findDomNode function? -


i jest test react component, component's inline style changed according different props value.

this example wanna do:

let firstchild = testutils.findrendereddomcomponentwithtag(renderedcomponent, 'div');     expect(firstchild.getdomnode().style).toequal({       fontsize: '20px'     }); 

this component props:

let renderedcomponent = testutils.renderintodocument(       <circleicon         size="small" /> 

and component dom test with:

return (       <div classname="circle-icon" style={boxstyle}>         <span classname={this.props.icon}></span>       </div>     ); 

if can inside boxstyle, can assert test result it.

thanks lot!

actually works.

usage:

firstchild.getdomnode().style.backgroundcolor 

Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -