Closed sushantdhiman closed 4 weeks ago
Sometimes deep links are used in a screen. I would like to wrap my test components in RouterContext so screen can be rendered for testing. Something like this
RouterContext
const appStore = /* get app redux store */ function Wrapper({ children }: React.PropsWithChildren<unknown>) { return ( <RouterContext.Provider value={{ match: {}, router: { push: sinon.spy(), go: sinon.spy(), createLocation: sinon.spy(), replace: sinon.spy(), createHref: sinon.spy(), isActive: sinon.spy(), matcher: { match: sinon.spy(), getRoutes: sinon.spy(), isActive: sinon.spy(), format: sinon.spy(), }, addNavigationListener: sinon.spy(), }, }} > <Provider store={appStore}>{children}</Provider> </RouterContext.Provider> ); }
Closing, as I no longer need this.
Sometimes deep links are used in a screen. I would like to wrap my test components in
RouterContext
so screen can be rendered for testing. Something like this