reactjs - TypeError: 'undefined' is not an object (evaluating 'this.props.people.map') -
i getting 'undefined' not object error when running test cases. here actual code.
class people extends react.component{ displayalert (email){ alert(email); } render (){ return ( <div>{ <ul key = {this.props.id}> <li> <button onclick= {this.displayalert.bind(this, this.props.email)}>{this.props.lastname + ', ' + this.props.firstname}</button> </li> </ul>} </div> ); } } class personlist extends react.component{ render () { /* people array of people*/ var items = this.props.people.map( function ( item ){ return <people id = {item.id} email = {item.email} firstname = {item.firstname} lastname = {item.lastname}> </people> }); return ( <div> {items} </div> ) } } react.render( <personlist people={ people } />, el );
also, have test case check "person-list has instance every person". fails too. here test case , error message
it( `has instance every person`, () => { let persons = scryrenderedcomponentswithtype( list, personitem ); expect( persons.length ).to.equal( people.length ); } );
phantomjs 1.9.8 (windows 7 0.0.0) person-list has instance every person failed assertionerror: expected 1 equal 2
i have test case make sure there no elements. fails too. here test case , error
it( `doesn't have elements`, () => { expect( domnode.queryselectorall( '> :not( ul )' ).length ).to.equal( 0 ); expect( domnode.queryselectorall( '> ul > :not( li )' ).length ).to.equal( 0 ); } );
phantomjs 1.9.8 (windows 7 0.0.0) person-list doesn't have elements failed domexception "error: syntax_err: dom exception 12" thrown, throw error :)
Comments
Post a Comment