Is it possible to render a react fragment to an image without spinning up a server

124 Views Asked by At

I would like to render a react fragment to an image similar to how react-test-renderer renders html, without needing to create a route for the test and spin up a complete server. So I would like to do something similar to this:

test("test is exemplified", () => {
  const image = renderer.create(
    <div class="container">
      <component-under-test />
      <component-under-test boolean-attribute />
      <component-under-test className="some-class"/>
    </div>).screenshot('./test-index.tsx');

  expect(image).toMatchImageSnapshot();
})

Is it possible to get puppeteer or playwright to render an app inline like that?

0

There are 0 best solutions below