Skip to content

Instantly share code, notes, and snippets.

@BrianJenney
Created August 3, 2021 22:57
Show Gist options
  • Save BrianJenney/c94678e96c7a2a95641f524ac94a9bca to your computer and use it in GitHub Desktop.
Save BrianJenney/c94678e96c7a2a95641f524ac94a9bca to your computer and use it in GitHub Desktop.
import { createMemoryHistory } from 'history';
export const renderWithRouterMatch = (
Component,
{ path = '/', route = '/', history = createMemoryHistory({ initialEntries: [route] }) } = {},
{ store } = {}
) => ({
...render(
<BrowserRouter>
<Router history={history}>
<ThemeProvider theme="bri">
<Provider store={store}>
<Route path={path} render={() => Component} />
</Provider>
</ThemeProvider>
</Router>
</BrowserRouter>
)
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment