reactjs - Shallow test component, complain about required props gotten from mapStateToProps and mapDispatchToProps -


i shallow test component, , know shallow test test 1 level deep. problem warnings because component requireing props received mapstatetoprops , mapdispatchtoprops. makes me want know how send props down shallow rendered component without duplicate methods. using jest , enzyme.

let's call component componenta wrapped in hoc connect of react-redux (assuming using there mapstatetoprops , mapdispatchtoprops in question). traditional way testing component is:

  1. get wrapped component: connect have static property named wrappedcomponent, out this:

    const extractedcomponent = componenta.wrappedcomponent; 
  2. mock functions , props , pass normal props extracted component:

    const wrapper = mount(<extractedcomponent connectfunctiona={mocka} ... />); 
  3. test normal component! :)


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -