* Mounts SessionProvider in a real React 19 root under jsdom with a real * QueryClient, capturing the live context value via a probe consumer.
()
| 77 | * QueryClient, capturing the live context value via a probe consumer. |
| 78 | */ |
| 79 | function renderProvider(): Harness { |
| 80 | ;(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true |
| 81 | const container = document.createElement('div') |
| 82 | const root: Root = createRoot(container) |
| 83 | const queryClient = new QueryClient({ |
| 84 | defaultOptions: { queries: { retry: false } }, |
| 85 | }) |
| 86 | |
| 87 | let latest: SessionHookResult | null = null |
| 88 | function Probe() { |
| 89 | latest = useContext(SessionContext) |
| 90 | return null |
| 91 | } |
| 92 | |
| 93 | act(() => { |
| 94 | root.render( |
| 95 | <QueryClientProvider client={queryClient}> |
| 96 | <SessionProvider> |
| 97 | <Probe /> |
| 98 | </SessionProvider> |
| 99 | </QueryClientProvider> |
| 100 | ) |
| 101 | }) |
| 102 | |
| 103 | return { |
| 104 | ctx: () => latest, |
| 105 | queryClient, |
| 106 | unmount: () => act(() => root.unmount()), |
| 107 | } |
| 108 | } |
| 109 | |
| 110 | /** |
| 111 | * Flush pending work inside an act() boundary. Drains the microtask queue and |
no test coverage detected