Skip to content

Instantly share code, notes, and snippets.

@stipsan
Last active June 16, 2017 09:34
Show Gist options
  • Save stipsan/1b75dfb077430d716ddd8052e8ead235 to your computer and use it in GitHub Desktop.
Save stipsan/1b75dfb077430d716ddd8052e8ead235 to your computer and use it in GitHub Desktop.
Testing with Jest: Tip #1
import renderer from 'react-test-renderer'
import Sidebar from '../Sidebar'
jest.mock('react-router-dom/Link', () => 'Link')
it('should render correctly', () => {
const component = renderer.create(<Sidebar />)
expect(component.toJSON()).toMatchSnapshot()
})
import Link from 'react-router-dom/Link'
export default () =>
<ul>
<li><Link to="/">Home</Link></li>
<li><Link to="/about">About</Link></li>
<li><Link to="/topics">Topics</Link></li>
</ul>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment