Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Custom centralized render for react-testing-library
import { render as r } from 'react-testing-library'
import { createStore } from 'redux'
import { Provider as ReduxProvider } from 'react-redux'
import { LocationProvider, createHistory } from "@reach/router"
import { AuthenicationProvider, createAuth } from '../auth'
import { reducer } from '../state'
export function reducer(ui, {
initialState = {},
store = createStore(reducer, initialState),
history = createHistory(),
auth = createAuth()
} = {}) {
const WrapperUI = () => (
<ReduxProvider store={store}>
<AuthenicationProvider auth={auth}>
<LocationProvider history={history}>{ui}</LocationProvider
</AuthenicationProvider>
</ReduxProvider>
)
return { ...r(<WrappedUI />), store, history }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.