After lots of copy/pasting a small utility that makes shallow rendering a React component a little easier, I decided to open source it. It’s calledrenderShallow, and it's now on Github and npm as render-shallow.
My motivation for it came when I started noticing that in most of the React component tests I wrote, I simply wanted a shallow rendered component to test. The ShallowRenderer API is a little verbose, between the creation and the getting of the output. So I started abstracting that (the .output returned from renderShallow). When I found myself wanting to rerender the component, either because of state or props changes, I added the ability to both re-fetch the output (rerender), or render the element again with new props (rerenderElement).
This post originally appeared on Ian's blog. If your company has a React project you need help with, please contact us!