Migrate tests from Jest to Vitest, updating setup and test files accordingly.

- Replace Jest imports and mocks with Vitest equivalents in setup and unit tests.
- Adjust test cases to use async imports and reset modules with Vitest.
- Add Vitest configuration file for test environment setup and coverage reporting.
This commit is contained in:
Max Kowalski
2025-06-27 19:14:05 +02:00
parent 5c1ced5900
commit 49a75f5ede
7 changed files with 1094 additions and 2230 deletions

View File

@ -1,25 +1,19 @@
// Jest test setup
import { jest } from '@jest/globals';
// Vitest test setup
import { vi } from 'vitest';
// Mock console methods to reduce noise in tests
global.console = {
...console,
log: jest.fn(),
warn: jest.fn(),
error: jest.fn(),
log: vi.fn(),
warn: vi.fn(),
error: vi.fn(),
};
// Set test environment variables
Object.defineProperty(process.env, 'NODE_ENV', {
value: 'test',
writable: true,
configurable: true,
});
process.env.NEXTAUTH_SECRET = 'test-secret';
process.env.NEXTAUTH_URL = 'http://localhost:3000';
// Mock node-fetch for transcript fetcher tests
jest.mock('node-fetch', () => ({
__esModule: true,
default: jest.fn(),
vi.mock('node-fetch', () => ({
default: vi.fn(),
}));