Created
January 6, 2020 22:15
-
-
Save hjumeau/e7d01df254014bfe9f87db04e7c05401 to your computer and use it in GitHub Desktop.
A simple test helper - store provider for react-testing-library
This file contains 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 { render, RenderOptions } from '@testing-library/react'; | |
import React from 'react'; | |
import { Provider } from 'react-redux'; | |
import { store } from '../../store'; | |
const Providers: React.FC = ({ children }) => { | |
return ( | |
<Provider store={store}> | |
{children} | |
</Provider> | |
); | |
}; | |
export const renderWithProviders = (ui: React.ReactElement, options?: RenderOptions) => | |
render(ui, { wrapper: Providers, ...options }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment