freshyo/apps/user-ui/tests/helpers/real-router.tsx
2026-09-26 13:41:46 +05:30

21 lines
688 B
TypeScript

/**
* Real-router render helper.
*
* IMPORTANT: only import this from a test file that does NOT mock expo-router.
* `jest.mock('expo-router', ...)` also affects `expo-router/testing-library`,
* so mixing the two in one file breaks the real router.
*
* Route keys mirror app/ (e.g. '(drawer)/(tabs)/home/index'); renderRouter
* strips the group segments, so that route is reachable at '/home'.
*/
import type React from 'react'
import { renderRouter } from 'expo-router/testing-library'
export interface RouteMap {
[route: string]: React.ComponentType<any>
}
export function renderRoute(routes: RouteMap, initialUrl: string) {
return renderRouter(routes, { initialUrl })
}