Files
auto_rfp/vitest.setup.ts
blank-black f912ce15de Add Vitest testing infrastructure with 173 unit tests
- Configure Vitest with coverage reporting and path aliases
- Add test scripts (test, test:run, test:coverage) to package.json
- Install vitest, @vitest/coverage-v8, vite-tsconfig-paths, vitest-mock-extended

Test coverage includes:
- validators: extract-questions, generate-response, llamaparse, multi-step-response
- errors: all API error classes with type guard
- services: FileValidator (file type/size validation), DefaultResponseService
- middleware: apiHandler and withApiHandler request validation

Add mock infrastructure for Prisma, OpenAI, and test fixtures
2025-12-26 11:41:08 -06:00

23 lines
642 B
TypeScript

import { afterEach, afterAll, vi } from 'vitest';
// Mock environment variables
vi.stubEnv('OPENAI_API_KEY', 'test-openai-key');
vi.stubEnv('LLAMACLOUD_API_KEY', 'test-llamacloud-key');
vi.stubEnv('DATABASE_URL', 'postgresql://test:test@localhost:5432/test');
vi.stubEnv('NEXT_PUBLIC_SUPABASE_URL', 'https://test.supabase.co');
vi.stubEnv('NEXT_PUBLIC_SUPABASE_ANON_KEY', 'test-anon-key');
vi.stubEnv('NEXT_PUBLIC_APP_URL', 'http://localhost:3000');
// Global fetch mock
global.fetch = vi.fn();
afterEach(() => {
// Reset all mocks between tests
vi.clearAllMocks();
});
afterAll(() => {
// Global teardown
vi.unstubAllEnvs();
});