javascript - Testing connected react component that needs params -


i'm trying test connected react component needs props.params.id call action creators. when try test component connected store "uncaught typeerror: cannot read property 'id' of undefined"

reactdom.render(   <provider store={store}>     <router history={history}>       <route path="/" component={app}>         <indexroute component={postsindex}/>         <route path="posts/:id" component={showpost}/>       </route>     </router>   </provider>   , document.queryselector('.container'));   describe('connectedshowpost', ()=> {     let initialstate = {       posts: { postslist: postslistdata, post: postdata, error: '' },       comments: {showcomments: false},       auth: {authenticated: true}     };      store = mockstore(initialstate);      connectedshowpost = testutils.renderintodocument(<provider store={store}><connectedshowpost/></provider>);     showpost = testutils.scryrenderedcomponentswithtype(connectedshowpost, showpost)[0];       expect(showpost.props.posts.post).toequal(postdata);   }) 

i've tried including params in store doesn't work since params not hooked store when used inside component.

i've tried passing in ownprops argument , didn't work either.

passing in connectedshowpost component props causes other state items in store undefined..

also tried directly set showpost.props.params = {id: '123} didnt work either..

any ideas on how test work?


Comments

Popular posts from this blog

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

mapreduce - Resource manager does not transit to active state from standby -

serialization - Convert Any type in scala to Array[Byte] and back -