We have a bit of repetition in our rerender calls here and it would be nice if we could avoid that. Let’s use the wrapper option for React Testing Library so we can avoid the repetition in our rerender calls.
Previous:
const { rerender, getByRole, getByText, queryByText, queryByRole } = render( <ErrorBoundary> <Bomb /> </ErrorBoundary>, ) rerender( <ErrorBoundary> <Bomb shouldThrow={true} /> </ErrorBoundary>, )
Now:
const { rerender, getByRole, getByText, queryByText, queryByRole } = render( <Bomb />, { wrapper: ErrorBoundary }, ) rerender(<Bomb shouldThrow={true} />)