opentui icon indicating copy to clipboard operation
opentui copied to clipboard

Add support for testing React components

Open remorses opened this issue 1 month ago • 2 comments

Added support for passing a custom renderer in React render and make it wait until React commits

I added a ready field to the TestRenderer to be able to await the React commit. Because React renders asynchronously

remorses avatar Oct 09 '25 16:10 remorses

i'm not sure on this one... i had started looking into changing the api for this previously but didn't finish it! i was leaning towards exposing a createRoot method that takes a renderer to align with standards.

Something like:

import { createCliRenderer } from "@opentui/core";
import { createRoot } from "@opentui/react";

const renderer = await createCliRenderer(<config>);
createRoot(renderer).render(<App />);

msmps avatar Oct 09 '25 17:10 msmps

That makes sense. I also have some issues creating the promise for ready in a way that does not create issues with Solid

remorses avatar Oct 09 '25 18:10 remorses

I think this was solved by #309

kommander avatar Nov 19 '25 11:11 kommander