Skip to content

Instantly share code, notes, and snippets.

@danielmoi
Last active March 14, 2017 03:43
Show Gist options
  • Select an option

  • Save danielmoi/ea598196931e10e64d618aefb3cadef4 to your computer and use it in GitHub Desktop.

Select an option

Save danielmoi/ea598196931e10e64d618aefb3cadef4 to your computer and use it in GitHub Desktop.

Enzyme tips

Mount or Shallow?

Testing component life cycle methods, like componentDidMount?

  • use mount and provide store

Testing state / props / clicks?

  • use shallow

Testing nested child components?

  • use mount

Inputs

Checkboxes

wrapper.find('input').simulate('change', { target: { checked: false } });

onBlur

wrapper.find('input').simulate('blur', { target: { value: '123' } });

Selects

wrapper.find('select').simulate('change', { target: { value: 123 } });

Misc

  • Using a connected component will result in functions passed in as props (eg stubs) to NOT be respected
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment