Created
September 17, 2025 13:19
-
-
Save marcelarie/290c583db966dd3023fb860b09f4f85d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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