Skip to content

Instantly share code, notes, and snippets.

@hjumeau
Created January 6, 2020 22:15
Show Gist options
  • Save hjumeau/e7d01df254014bfe9f87db04e7c05401 to your computer and use it in GitHub Desktop.
Save hjumeau/e7d01df254014bfe9f87db04e7c05401 to your computer and use it in GitHub Desktop.
A simple test helper - store provider for react-testing-library
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