import { AnyAction, configureStore } from '@reduxjs/toolkit'; import { ThunkMiddlewareFor } from '@reduxjs/toolkit/dist/getDefaultMiddleware'; import { render as rtlRender } from '@testing-library/react'; import React from 'react'; import { Provider } from 'react-redux'; import { createRootReducer } from 'app/core/reducers/root'; import { StoreState } from 'app/types'; import { mockNavModel } from './mocks/navModel'; function render( ui: React.ReactElement, { preloadedState = { navIndex: mockNavModel }, store = configureStore< StoreState, AnyAction, ReadonlyArray> >({ reducer: createRootReducer(), preloadedState, middleware: (getDefaultMiddleware) => getDefaultMiddleware({ thunk: true, serializableCheck: false, immutableCheck: false }), }), ...renderOptions }: { preloadedState?: Partial; store?: ReturnType } = {} ) { function Wrapper({ children }: { children: React.ReactNode }) { return {children}; } return rtlRender(ui, { wrapper: Wrapper, ...renderOptions }); } export { render };