Skip to content

Instantly share code, notes, and snippets.

@sonicoder86
Created April 15, 2020 18:26
Show Gist options
  • Save sonicoder86/851b3ce3aeccf1c6ba0cd8528ca9788a to your computer and use it in GitHub Desktop.
Save sonicoder86/851b3ce3aeccf1c6ba0cd8528ca9788a to your computer and use it in GitHub Desktop.
React Testing Crash Course - part 13
import { Router } from 'react-router-dom';
import { createMemoryHistory } from 'history';
import { render } from '@testing-library/react';
describe('Routing', () => {
it('should display route', () => {
const history = createMemoryHistory();
history.push('/modify');
const { getByTestId } = render(
<Router history={history}>
<App/>
</Router>
);
expect(getByTestId('location-display')).toHaveTextContent('/modify');
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment