搜索文档
Home > @lynx-js/react/testing-library > render
Render into the page. It should be used with cleanup.
Signature:
export function render<Q extends Queries>( ui: ComponentChild, options?: RenderOptions<Q>, ): RenderResult<Q>;
Returns:
RenderResult<Q>
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> `);