import { SafeRunResult } from './safe-run'; import { TestClock } from './test-clock'; export interface TestHarnessOptions { /** * Automatically clean up resources after each test */ autoCleanup?: boolean; /** * Enable time control features */ enableTimeFreezing?: boolean; /** * Custom setup timeout in milliseconds */ setupTimeout?: number; /** * Custom teardown timeout in milliseconds */ teardownTimeout?: number; /** * Enable detailed logging for debugging */ verbose?: boolean; } export interface TestHarnessState { readonly isInitialized: boolean; readonly isSetup: boolean; readonly setupTime: Date | null; readonly teardownTime: Date | null; readonly resourceCount: number; readonly hasErrors: boolean; } export interface TestResource { readonly id: string; readonly type: string; readonly created: Date; dispose(): Promise | void; } export declare abstract class TestHarness { protected readonly options: Required; protected _isInitialized: boolean; protected _isSetup: boolean; protected _setupTime: Date | null; protected _teardownTime: Date | null; protected _resources: Map; protected _errors: Error[]; protected _testClock: TestClock | null; constructor(options?: TestHarnessOptions); /** * Initialize the test harness. Must be called before using the harness. */ initialize(): Promise; /** * Set up the test environment. Called before each test. */ setup(): Promise; /** * Clean up the test environment. Called after each test. */ teardown(): Promise; /** * Reset the harness to a clean state without full teardown/setup cycle */ reset(): Promise; /** * Dispose of the harness and all resources. Called when completely done. */ dispose(): Promise; /** * Get the current state of the test harness */ getState(): TestHarnessState; /** * Get all errors that occurred during harness operations */ getErrors(): readonly Error[]; /** * Register a resource for automatic cleanup */ protected registerResource(resource: TestResource): void; /** * Unregister a resource */ protected unregisterResource(resourceId: string): boolean; /** * Get access to the test clock (if enabled) */ protected getTestClock(): TestClock; /** * Execute a function safely and return result/error tuple */ protected safeExecute(fn: () => T): SafeRunResult; protected safeExecute(fn: () => Promise): Promise>; /** * Assert that an operation throws the expected error type */ protected expectError(errorType: new (...args: any[]) => E): (result: SafeRunResult) => E; /** * Assert that an operation succeeds and return the value */ protected expectSuccess(result: SafeRunResult): T; /** * Log a message if verbose logging is enabled */ protected log(message: string): void; /** * Ensure the harness is initialized before proceeding */ protected ensureInitialized(): void; /** * Ensure the harness is set up before proceeding */ protected ensureSetup(): void; /** * Dispose of all registered resources */ private disposeAllResources; /** * Perform harness-specific initialization logic */ protected abstract performInitialization(): Promise; /** * Perform harness-specific setup logic */ protected abstract performSetup(): Promise; /** * Perform harness-specific teardown logic */ protected abstract performTeardown(): Promise; /** * Perform harness-specific reset logic */ protected abstract performReset(): Promise; /** * Perform harness-specific disposal logic */ protected abstract performDisposal(): Promise; } export declare class SimpleTestHarness extends TestHarness { private _customSetupFn; private _customTeardownFn; constructor(options?: TestHarnessOptions & { setupFn?: () => Promise | void; teardownFn?: () => Promise | void; }); protected performInitialization(): Promise; protected performSetup(): Promise; protected performTeardown(): Promise; protected performReset(): Promise; protected performDisposal(): Promise; } export declare class TestResourceBuilder { private _id; private _type; private _disposeFn; constructor(type: string, id?: string); withId(id: string): this; withDisposal(disposeFn: () => Promise | void): this; build(): TestResource; static create(type: string, id?: string): TestResourceBuilder; }