diff --git a/frontend/app/__tests__/layout.test.tsx b/frontend/app/__tests__/layout.test.tsx index dc625b3..2df8255 100644 --- a/frontend/app/__tests__/layout.test.tsx +++ b/frontend/app/__tests__/layout.test.tsx @@ -2,6 +2,24 @@ import React from 'react'; import { render, screen } from '@testing-library/react'; import RootLayout, { metadata } from '../layout'; +// Suppress console.error for DOM nesting warnings in tests +// (html cannot be child of div - expected when testing Next.js RootLayout) +const originalConsoleError = console.error; +beforeAll(() => { + console.error = jest.fn((...args) => { + const message = args.map(arg => String(arg)).join(' '); + // Suppress DOM nesting warnings that occur when testing RootLayout + if (message.includes('cannot be a child of') || message.includes('hydration error')) { + return; + } + originalConsoleError.apply(console, args); + }); +}); + +afterAll(() => { + console.error = originalConsoleError; +}); + // Mock the ThemeProvider and Providers jest.mock('@/lib/theme', () => ({ ThemeProvider: ({ children }: { children: React.ReactNode }) =>
{children}
, diff --git a/frontend/lib/hooks/__tests__/useInteractiveTerminal.test.tsx b/frontend/lib/hooks/__tests__/useInteractiveTerminal.test.tsx index 78887fb..09e669a 100644 --- a/frontend/lib/hooks/__tests__/useInteractiveTerminal.test.tsx +++ b/frontend/lib/hooks/__tests__/useInteractiveTerminal.test.tsx @@ -1,6 +1,23 @@ import { renderHook, act } from '@testing-library/react'; import { useInteractiveTerminal } from '../useInteractiveTerminal'; +// Suppress console output during tests (terminal initialization logs) +const originalConsoleLog = console.log; +const originalConsoleWarn = console.warn; +const originalConsoleError = console.error; + +beforeAll(() => { + console.log = jest.fn(); + console.warn = jest.fn(); + console.error = jest.fn(); +}); + +afterAll(() => { + console.log = originalConsoleLog; + console.warn = originalConsoleWarn; + console.error = originalConsoleError; +}); + // Mock socket.io-client const mockSocket = { on: jest.fn(), diff --git a/frontend/lib/hooks/__tests__/useTerminalModalState.test.tsx b/frontend/lib/hooks/__tests__/useTerminalModalState.test.tsx index fb17b24..3ee86f3 100644 --- a/frontend/lib/hooks/__tests__/useTerminalModalState.test.tsx +++ b/frontend/lib/hooks/__tests__/useTerminalModalState.test.tsx @@ -1,6 +1,17 @@ import { renderHook, act } from '@testing-library/react'; import { useTerminalModalState } from '../useTerminalModalState'; +// Suppress console.warn during tests (fallback mode warnings are expected) +const originalConsoleWarn = console.warn; + +beforeAll(() => { + console.warn = jest.fn(); +}); + +afterAll(() => { + console.warn = originalConsoleWarn; +}); + // Mock MUI hooks jest.mock('@mui/material', () => ({ ...jest.requireActual('@mui/material'),