From e79c3660f5157629e8f652bd47a53b1ba8be8d9c Mon Sep 17 00:00:00 2001 From: Yunfei He Date: Tue, 26 May 2026 01:00:56 +0800 Subject: [PATCH] test: verify error boundary routes post-mount errors through exit() Vue's errorHandler (installed after mount) already catches render-time errors from nested components and routes them through exit(err), providing error boundary behavior matching Ink's design. Co-Authored-By: Claude Opus 4.7 (1M context) --- .../lifecycle/error-boundary.test.tsx | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 packages/runtime-tests/integration/lifecycle/error-boundary.test.tsx diff --git a/packages/runtime-tests/integration/lifecycle/error-boundary.test.tsx b/packages/runtime-tests/integration/lifecycle/error-boundary.test.tsx new file mode 100644 index 0000000..0535082 --- /dev/null +++ b/packages/runtime-tests/integration/lifecycle/error-boundary.test.tsx @@ -0,0 +1,33 @@ +import { defineComponent, nextTick, shallowRef } from "vue"; +import { expect, test } from "vite-plus/test"; +import { render } from "@vue-tui/testing"; +import { Box, Text } from "@vue-tui/runtime"; + +test("render-time throw in nested component rejects waitUntilExit", async () => { + const trigger = shallowRef(false); + + const Child = defineComponent(() => { + return () => { + if (trigger.value) throw new Error("child render boom"); + return child ok; + }; + }); + + const App = defineComponent(() => { + return () => ( + + + + ); + }); + + const { lastFrame, waitUntilExit } = await render(App); + expect(lastFrame()).toContain("child ok"); + + // Trigger the error in the child component's render function + trigger.value = true; + await nextTick(); + + // The error should route through errorHandler → exit(err) → rejects waitUntilExit + await expect(waitUntilExit()).rejects.toThrow("child render boom"); +});