MCPcopy
hub / github.com/getsentry/sentry / render

Function render

tests/js/sentry-test/reactTestingLibrary.tsx:318–364  ·  view source on GitHub ↗

* Try avoiding unnecessary context and just mount your component. If it works, * then you dont need anything else. * * render( ); * * If your component requires additional context you can pass it in the * options. * * To test route changes, this function returns a `router`

(ui: React.ReactElement, options: RenderOptions = {})

Source from the content-addressed store, hash-verified

316 * location, pass an `initialRouterConfig`.
317 */
318function render(ui: React.ReactElement, options: RenderOptions = {}): RenderReturn {
319 const {initialEntry, config, outletContext} = getInitialRouterConfig(options);
320
321 const history = createMemoryHistory({
322 initialEntries: [initialEntry],
323 });
324
325 const AllTheProviders = makeAllTheProviders({
326 organization: options.organization,
327 additionalWrapper: options.additionalWrapper,
328 });
329
330 const memoryRouter = makeRouter({
331 children: <AllTheProviders>{ui}</AllTheProviders>,
332 history,
333 config,
334 outletContext,
335 });
336
337 const renderResult = rtl.render(
338 <RouterProvider router={memoryRouter} future={{v7_startTransition: true}} />,
339 options
340 );
341
342 const rerender = (newUi: React.ReactElement) => {
343 const newRouter = makeRouter({
344 children: <AllTheProviders>{newUi}</AllTheProviders>,
345 history,
346 config,
347 outletContext,
348 });
349
350 renderResult.rerender(
351 <RouterProvider router={newRouter} future={{v7_startTransition: true}} />
352 );
353 // Force the router to update children
354 rtl.act(() => newRouter.revalidate());
355 };
356
357 const testRouter = new TestRouter(memoryRouter);
358
359 return {
360 ...renderResult,
361 rerender,
362 router: testRouter,
363 } as RenderReturn;
364}
365
366function renderHookWithProviders<Result = unknown, Props = unknown>(
367 callback: (initialProps: Props) => Result,

Calls 4

makeAllTheProvidersFunction · 0.85
makeRouterFunction · 0.85
getInitialRouterConfigFunction · 0.70
renderMethod · 0.45

Tested by 15

renderSentryAppDetailsFunction · 0.72
renderPDTFunction · 0.72
createWrapperFunction · 0.72
renderGridFunction · 0.72
createWrapperFunction · 0.72
setupTestComponentFunction · 0.72
renderComponentFunction · 0.72
renderComponentFunction · 0.72
renderModalFunction · 0.72
renderModalFunction · 0.72
createWrapperFunction · 0.72
renderModalFunction · 0.72