fix(tests): suppress expected console output during tests

Mock console.error and console.log in test setup to prevent
noisy stderr output from error handling tests. The error
messages were expected behavior being tested, not actual failures.
This commit is contained in:
Claude
2026-01-07 08:58:45 +00:00
parent 7d0cbaad96
commit 48870c72ad

View File

@@ -1,5 +1,20 @@
import "@testing-library/jest-dom";
import { vi } from "vitest";
import { vi, beforeAll, afterAll } from "vitest";
// Suppress console.error and console.log during tests to reduce noise
// These are expected outputs from error handling tests
const originalConsoleError = console.error;
const originalConsoleLog = console.log;
beforeAll(() => {
console.error = vi.fn();
console.log = vi.fn();
});
afterAll(() => {
console.error = originalConsoleError;
console.log = originalConsoleLog;
});
// Mock environment variables
process.env.NEXTAUTH_SECRET = "test-secret";