I'm trying to add redux to test components. Please tell me how to write the renderWithRedux function correctly, I could not find a case with typescript and configureStore...
import { render } from "@testing-library/react"
import { Provider } from "react-redux"
import { BrowserRouter } from "react-router-dom"
import { appReducer } from "../redux/appReducer"
import thunkMiddleware from 'redux-thunk'
import { configureStore } from "@reduxjs/toolkit"
export const renderWithRedux = (
component: React.ReactNode,
{ initialState = {}, store = configureStore({
reducer: appReducer,
middleware: [thunkMiddleware]
}),
}) => {
return {
...render(
<BrowserRouter>
<Provider store={store}>
{component}
</Provider>
</BrowserRouter>)
}
}