Skip to main content

renderComponent

Callable

  • renderComponent(element: ReactElement<any, string | JSXElementConstructor<any>>, stripped?: boolean): Promise<string>

  • Can be used to render a React component with Ink and return the rendered result as a terminal compatible string. If stripped is true, it will strip ANSI escape escape sequences.

    import { renderComponent } from '@boost/cli/test';
    import TestComponent from '../src/components/TestComponent';

    it('renders a component', async () => {
    expect(await renderComponent(<TestComponent />)).toMatchSnapshot();
    });

    As an alternative, we also suggest using the official ink-testing-library.