From 86666b050cad460126d3073bb377b828419d3f95 Mon Sep 17 00:00:00 2001 From: hiro-nikaitou Date: Sun, 12 Jul 2026 20:42:13 +0800 Subject: [PATCH] Add test: errors thrown again after reset are caught This test verifies that when an error boundary resets (via resetKeys change) but the child component still throws, the error boundary catches the error again and displays the fallback. Previously this edge case was marked as a TODO and had no test coverage. --- lib/components/ErrorBoundary.test.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/components/ErrorBoundary.test.tsx b/lib/components/ErrorBoundary.test.tsx index 31cc9c5..c5d8409 100644 --- a/lib/components/ErrorBoundary.test.tsx +++ b/lib/components/ErrorBoundary.test.tsx @@ -155,6 +155,15 @@ describe("ErrorBoundary", () => { expect(container.textContent).toBe("Content"); }); + it("should catch errors thrown again after reset", () => { + shouldThrow = true; + render({ resetKeys: [1] }); + expect(container.textContent).toBe("Error"); + + render({ resetKeys: [2] }); + expect(container.textContent).toBe("Error"); + }); + it("should render a null fallback if specified", () => { shouldThrow = true; act(() => { @@ -359,6 +368,5 @@ describe("ErrorBoundary", () => { }); // TODO Various cases with resetKeys changing (length, order, etc) - // TODO Errors thrown again after reset are caught // TODO Nested error boundaries if a fallback throws });