Created
July 10, 2021 01:20
-
-
Save akinncar/6dbc7d47a6cda6853c2be40ad0bc3134 to your computer and use it in GitHub Desktop.
Mock contexts on testing library
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import '__mocks__/broadcast' | |
import { ReactChildren, ReactChild } from 'react' | |
import { render } from '@testing-library/react' | |
import { GlobalStyles } from 'styles' | |
import { ToastContainer } from 'components/Toast' | |
import { AuthProvider } from 'contexts/AuthContext' | |
import { SidebarProvider } from 'contexts/SidebarContext' | |
function customRender(children: ReactChild | ReactChildren) { | |
return render( | |
<> | |
<ToastContainer /> | |
<GlobalStyles /> | |
<AuthProvider> | |
<SidebarProvider>{children}</SidebarProvider> | |
</AuthProvider> | |
</> | |
) | |
} | |
export * from '@testing-library/react' | |
export { customRender as render } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment