diff --git a/frontend/src/App.test.tsx b/frontend/src/App.test.tsx index e761bb37..c73edb15 100644 --- a/frontend/src/App.test.tsx +++ b/frontend/src/App.test.tsx @@ -160,6 +160,7 @@ describe("App", () => { }); it("shows error when openProject fails", async () => { + const errorSpy = vi.spyOn(console, "error").mockImplementation(() => {}); mockedApi.openProject.mockRejectedValue(new Error("Path does not exist")); await renderApp(); @@ -182,6 +183,7 @@ describe("App", () => { await waitFor(() => { expect(screen.getByText(/Path does not exist/)).toBeInTheDocument(); }); + errorSpy.mockRestore(); }); it("shows known projects list", async () => { diff --git a/frontend/src/api/agents.test.ts b/frontend/src/api/agents.test.ts index 26e4714f..5a47ad44 100644 --- a/frontend/src/api/agents.test.ts +++ b/frontend/src/api/agents.test.ts @@ -266,6 +266,8 @@ describe("subscribeAgentStream", () => { }); it("handles malformed JSON without throwing", () => { + vi.spyOn(console, "error").mockImplementation(() => {}); + subscribeAgentStream("42_story_test", "coder", vi.fn()); expect(() => { diff --git a/frontend/src/components/Chat.commands.test.tsx b/frontend/src/components/Chat.commands.test.tsx index 943d4d3e..150d52b2 100644 --- a/frontend/src/components/Chat.commands.test.tsx +++ b/frontend/src/components/Chat.commands.test.tsx @@ -472,9 +472,16 @@ describe("Slash command handling (Story 374)", () => { }); describe("Story 1058: WebSocket errors do not appear in chat", () => { + let consoleSpy: ReturnType; + beforeEach(() => { capturedWsHandlers = null; setupMocks(); + consoleSpy = vi.spyOn(console, "error").mockImplementation(() => {}); + }); + + afterEach(() => { + consoleSpy.mockRestore(); }); it("does not add a chat message when onError is called", async () => { diff --git a/frontend/src/components/selection/usePathCompletion.test.ts b/frontend/src/components/selection/usePathCompletion.test.ts index 0685b41c..5f46b01d 100644 --- a/frontend/src/components/selection/usePathCompletion.test.ts +++ b/frontend/src/components/selection/usePathCompletion.test.ts @@ -227,6 +227,7 @@ describe("usePathCompletion hook", () => { }); it("sets completionError when listDirectoryAbsolute throws an Error", async () => { + const errorSpy = vi.spyOn(console, "error").mockImplementation(() => {}); mockListDir.mockRejectedValue(new Error("Permission denied")); const { result } = renderHook(() => @@ -242,9 +243,13 @@ describe("usePathCompletion hook", () => { await waitFor(() => { expect(result.current.completionError).toBe("Permission denied"); }); + + expect(errorSpy).toHaveBeenCalledWith(new Error("Permission denied")); + errorSpy.mockRestore(); }); it("sets generic completionError when listDirectoryAbsolute throws a non-Error", async () => { + const errorSpy = vi.spyOn(console, "error").mockImplementation(() => {}); mockListDir.mockRejectedValue("some string error"); const { result } = renderHook(() => @@ -262,6 +267,9 @@ describe("usePathCompletion hook", () => { "Failed to compute suggestion.", ); }); + + expect(errorSpy).toHaveBeenCalledWith("some string error"); + errorSpy.mockRestore(); }); it("clears suggestionTail when selected match path does not start with input", async () => {