Initial commit

Signed-off-by: Ilan Bigio <ilan@openai.com>
This commit is contained in:
Ilan Bigio
2025-04-16 12:56:08 -04:00
commit 59a180ddec
163 changed files with 30587 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
import type React from "react";
import { render } from "ink-testing-library";
import stripAnsi from "strip-ansi";
/**
* Render an Ink component for testing.
*
* Returns the full testinglibrary utils plus `lastFrameStripped()` which
* yields the latest rendered frame with ANSI escape codes removed so that
* assertions can be colouragnostic.
*/
export function renderTui(ui: React.ReactElement): any {
const utils = render(ui);
const lastFrameStripped = () => stripAnsi(utils.lastFrame() || "");
// A tiny helper that waits for Ink's internal promises / timers to settle
// so the next `lastFrame()` call reflects the latest UI state.
const flush = async () =>
new Promise<void>((resolve) => setTimeout(resolve, 0));
return {
...utils,
lastFrameStripped,
flush,
};
}