UNPKG

@dbs-portal/tool-mock

Version:

API mocking toolkit using MSW for DBS Portal development workflows

158 lines 4.04 kB
/** * Testing utilities types */ import type { RequestHandler } from 'msw'; /** * Test setup configuration */ export interface TestSetupConfig { /** Test handlers */ handlers?: RequestHandler[]; /** Auto-setup MSW */ autoSetup?: boolean; /** Test environment */ environment?: 'jsdom' | 'node' | 'happy-dom'; /** Global test configuration */ global?: { /** Global test timeout */ timeout?: number; /** Setup files */ setupFiles?: string[]; /** Teardown files */ teardownFiles?: string[]; }; } /** * Mock assertion configuration */ export interface MockAssertionConfig { /** Expected call count */ callCount?: number; /** Expected method */ method?: string; /** Expected URL pattern */ url?: string | RegExp; /** Expected request body */ body?: any; /** Expected headers */ headers?: Record<string, string>; /** Timeout for assertion */ timeout?: number; } /** * Test helper configuration */ export interface TestHelperConfig { /** Default delay for async operations */ defaultDelay?: number; /** Default timeout for assertions */ defaultTimeout?: number; /** Auto-cleanup after tests */ autoCleanup?: boolean; /** Verbose logging */ verbose?: boolean; } /** * Mock call information */ export interface MockCallInfo { /** Request method */ method: string; /** Request URL */ url: string; /** Request headers */ headers: Record<string, string>; /** Request body */ body?: any; /** Timestamp */ timestamp: number; /** Response status */ responseStatus?: number; /** Response data */ responseData?: any; } /** * Test scenario configuration */ export interface TestScenarioConfig { /** Scenario name */ name: string; /** Scenario description */ description?: string; /** Setup function */ setup?: () => Promise<void> | void; /** Teardown function */ teardown?: () => Promise<void> | void; /** Mock handlers for this scenario */ handlers?: RequestHandler[]; /** Expected behavior */ expectations?: MockAssertionConfig[]; } /** * Performance test configuration */ export interface PerformanceTestConfig { /** Number of concurrent requests */ concurrency?: number; /** Total number of requests */ totalRequests?: number; /** Request timeout */ timeout?: number; /** Warmup requests */ warmupRequests?: number; /** Performance thresholds */ thresholds?: { /** Maximum average response time (ms) */ maxAvgResponseTime?: number; /** Maximum 95th percentile response time (ms) */ maxP95ResponseTime?: number; /** Minimum requests per second */ minRps?: number; }; } /** * Test data factory configuration */ export interface TestDataFactoryConfig<T = any> { /** Factory name */ name: string; /** Data factory function */ factory: (overrides?: Partial<T>) => T; /** Default data set */ defaults?: Partial<T>; /** Validation function */ validate?: (data: T) => boolean; } /** * Integration test configuration */ export interface IntegrationTestConfig { /** API base URL */ apiBaseUrl?: string; /** Authentication configuration */ auth?: { /** Auth token */ token?: string; /** Auth headers */ headers?: Record<string, string>; /** Auth setup function */ setup?: () => Promise<void> | void; }; /** Database configuration */ database?: { /** Database URL */ url?: string; /** Setup function */ setup?: () => Promise<void> | void; /** Cleanup function */ cleanup?: () => Promise<void> | void; }; /** External services */ externalServices?: Record<string, { /** Service URL */ url: string; /** Mock handlers */ handlers?: RequestHandler[]; }>; } //# sourceMappingURL=types.d.ts.map