Skip to content

Instantly share code, notes, and snippets.

@marcelarie
Created September 17, 2025 13:19
Show Gist options
  • Save marcelarie/290c583db966dd3023fb860b09f4f85d to your computer and use it in GitHub Desktop.
Save marcelarie/290c583db966dd3023fb860b09f4f85d to your computer and use it in GitHub Desktop.
const testRender = (
children: ReactElement,
storeInitialState?: Partial<RootState>,
routerState: RouterState = {},
config?: TestRenderConfig
) => {
const testStore = storeInitialState ? createTestStore(storeInitialState) : store;
const renderResult = render(children, {
wrapper: props => <TestProvider store={testStore} {...routerState} {...config} {...props} />,
...config,
});
const getLocationPathname = () => {
const locationDisplay = renderResult.getByTestId(LOCATION_DISPLAY_ID);
return locationDisplay.textContent;
};
return {
store: testStore,
locationTestID: LOCATION_DISPLAY_ID,
getLocationPathname,
...renderResult,
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment