Created
November 7, 2022 18:27
-
-
Save Glaucoed/1c97f733f7a3531f72af923c03dcd873 to your computer and use it in GitHub Desktop.
renderWithRouter Context Test
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
| import React from 'react'; | |
| import { Router } from 'react-router-dom'; | |
| import { createMemoryHistory } from 'history'; | |
| import { render } from '@testing-library/react'; | |
| const renderWithRouter = (component, route = '/') => { | |
| const history = createMemoryHistory({ initialEntries: [route] }); | |
| return ({ | |
| ...render(<Router history={ history }>{component}</Router>), history, | |
| }); | |
| }; | |
| export default renderWithRouter; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment