For AI agents: the complete documentation index is available at /next/llms.txt, the full documentation bundle is available at /next/llms-full.txt, and this page is available as Markdown at /next/api/reactlynx-testing-library/Function.render.md.
Lynx
  • English
  • reactlynx-testing-library / render

    render()

    function render<Q>(ui: ReactNode, options?: RenderOptions<Q>): RenderResult<Q>

    Render into the page. It should be used with cleanup.

    Type Parameters

    Type Parameter
    Q extends Queries

    Parameters

    ParameterType
    uiReactNode
    options?RenderOptions<Q>

    Returns

    RenderResult<Q>

    Example

    import { render} from '@lynx-js/react/testing-library'
    
    const WrapperComponent = ({ children }) => (
        <view data-testid='wrapper'>{children}</view>
    );
    const Comp = () => {
      return <view data-testid='inner' style="background-color: yellow;" />;
    };
    const { container, getByTestId } = render(<Comp />, {
      wrapper: WrapperComponent,
    });
    expect(getByTestId('wrapper')).toBeInTheDocument();
    expect(container.firstChild).toMatchInlineSnapshot(`
      <view
        data-testid="wrapper"
      >
        <view
          data-testid="inner"
          style="background-color: yellow;"
        />
      </view>
    `);

    Defined in

    index.d.ts:1300

    Except as otherwise noted, this work is licensed under a Creative Commons Attribution 4.0 International License, and code samples are licensed under the Apache License 2.0.