import type { RenderOptions } from '@testing-library/react' import { render } from '@testing-library/react' import userEvent from '@testing-library/user-event' import { LocalizationProvider } from '@mui/lab' import { ThemeProvider } from '@mui/material' import AdapterDateFns from '@mui/lab/AdapterDateFns' import type { InitialEntry, MemoryHistory } from 'history' import { createMemoryHistory } from 'history' import { SnackbarProvider } from 'notistack' import { Suspense } from 'react' import { Route, Router, Routes } from 'react-router-dom' import type { Cache, SWRConfiguration } from 'swr' import { SWRConfig } from 'swr' export const cache = new Map() const ThemeModeProvider = ({ children }: any) => { return {children} } export interface ProviderOptions extends RenderOptions { initialEntries?: Array route?: string swrConfig?: SWRConfiguration } interface ProvidersProps extends ProviderOptions { children: React.ReactNode history: MemoryHistory swrCache: Cache } const Providers = ({ children, history, route, swrCache }: ProvidersProps) => { let Wrapper = ( swrCache, }} > {children} ) if (route) { Wrapper = ( ) } return Wrapper } const renderWithProviders = ( ui: React.ReactElement, options: ProviderOptions = {}, ) => { const { initialEntries = [], route, ...rest } = options const history = createMemoryHistory({ initialEntries }) const swrCache = new Map(cache) const rtl = render(ui, { wrapper: ({ children }) => ( {children} ), ...rest, }) return { ...rtl, rerender: (ui: React.ReactElement, rerenderOptions?: ProviderOptions) => renderWithProviders(ui, { container: rtl.container, ...options, ...rerenderOptions, }), history, swrCache, } } export { screen } from '@testing-library/react' export { renderWithProviders as render, userEvent as user }