reactlynx-testing-library / render

Function: render()

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

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

Type Parameters

Type Parameter
Q extends Queries

Parameters

Parameter Type
ui ComponentChild
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:1234

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.