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) <noreply@anthropic.com>
This commit is contained in:
@@ -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 <Text>child ok</Text>;
|
||||
};
|
||||
});
|
||||
|
||||
const App = defineComponent(() => {
|
||||
return () => (
|
||||
<Box>
|
||||
<Child />
|
||||
</Box>
|
||||
);
|
||||
});
|
||||
|
||||
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");
|
||||
});
|
||||
Reference in New Issue
Block a user