Skip to content

Instantly share code, notes, and snippets.

@Glaucoed
Created November 7, 2022 18:27
Show Gist options
  • Select an option

  • Save Glaucoed/1c97f733f7a3531f72af923c03dcd873 to your computer and use it in GitHub Desktop.

Select an option

Save Glaucoed/1c97f733f7a3531f72af923c03dcd873 to your computer and use it in GitHub Desktop.
renderWithRouter Context Test
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