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"); +});