Files
vue-tui/packages/runtime-tests/integration/pty/fixtures/exit-with-static.tsx
T
Yunfei He 7d6a92ea15 test(runtime): lock render lifecycle, exit, error-handling, alt-screen, use-stdout (Ink parity) (#115)
Round-2 test-only locks (behaviors already at parity with Ink test/render.tsx,
exit.tsx, errors.tsx, hooks.tsx):
- resize re-render reflows content to the new width (exact narrowed round-border bytes)
  + consecutive width decreases each clear; onRender fires exactly once per rerender
  (tightened from `>`); onMounted runs before the first frame write callback (#596);
  bsu/esu wraps a trailing throttled content change, and an unchanged trailing rerender
  emits neither; patchConsole puts a log above the live frame.
- exit-with-static #397 non-duplication (A/B/C each render once) — the fixture is fixed
  to function slots so no [Vue warn] pollutes stdout; exit-with-thrown-error via run()'s
  strict exit-0 gate; DEV is inert; the process stays alive ~500ms while raw mode is held.
- raw mode is disabled on the thrown-error cleanup path; the unhandledRejection test moved
  to a *.sequential file (it mutates a process-global listener).
- alternate-screen enter sequence hides the cursor; useStdout().write() preserves the
  frame with the external write ordered above it.

Codex-reviewed GENUINE.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-01 03:07:35 +08:00

32 lines
868 B
TypeScript

import { createApp, Static, Text, useApp } from "@vue-tui/runtime";
import { defineComponent, h, onMounted } from "vue";
const App = defineComponent(() => {
const { exit } = useApp();
onMounted(() => {
exit(new Error("errored"));
});
// Use a function default slot for <Text> (h(Text, props, () => child)) so Vue
// does not warn "Non-function value encountered for default slot" — those warns
// would print to stdout and pollute the duplication assertion in exit.test.ts.
return () => (
<>
<Static items={["A", "B", "C"]}>
{{ default: ({ item }: { item: string }) => h(Text, { key: item }, () => item) }}
</Static>
{h(Text, null, () => "Dynamic")}
</>
);
});
const app = createApp(App);
app.mount();
try {
await app.waitUntilExit();
} catch (error: unknown) {
console.log((error as Error).message);
}