/** * Vitest Global Setup * Initializes MSW server for all test suites */ import { beforeAll, afterEach, afterAll, vi } from 'vitest' import { setupServer } from 'msw/node' import { handlers } from './mocks/handlers' /** * MSW Server Instance * Automatically intercepts HTTP requests during tests */ export const server = setupServer(...handlers) /** * Global Test Lifecycle Hooks */ // Enable request interception before all tests beforeAll(() => { server.listen({ onUnhandledRequest: 'warn' }) }) // Reset handlers after each test to ensure test isolation afterEach(() => { server.resetHandlers() }) // Disable request interception after all tests afterAll(() => { server.close() }) /** * Mock console methods to reduce test output noise * Remove these if debugging is needed */ beforeAll(() => { // Optional: suppress console.warn for unhandled requests // vi.spyOn(console, 'warn').mockImplementation(() => {}) })