tui-tester
Version:
End-to-end testing framework for terminal user interfaces
89 lines (85 loc) • 2.35 kB
TypeScript
import { i as TerminalTester, j as TestScenario, d as TesterConfig, l as TestResult, k as TestStep } from '../types-I_UaGSPL.js';
/**
* Test Runner
* High-level utilities for running terminal UI tests
*/
interface TestRunnerOptions {
beforeAll?: () => Promise<void>;
afterAll?: () => Promise<void>;
beforeEach?: (tester: TerminalTester) => Promise<void>;
afterEach?: (tester: TerminalTester) => Promise<void>;
timeout?: number;
retries?: number;
parallel?: boolean;
debug?: boolean;
}
declare class TestRunner {
private options;
private results;
constructor(options?: TestRunnerOptions);
/**
* Run a single test scenario
*/
runScenario(scenario: TestScenario, config: TesterConfig): Promise<TestResult>;
/**
* Run a single test step
*/
private runStep;
/**
* Run multiple scenarios
*/
runScenarios(scenarios: TestScenario[], config: TesterConfig): Promise<TestResult[]>;
/**
* Run scenario with retries
*/
private runScenarioWithRetries;
/**
* Get test results
*/
getResults(): TestResult[];
/**
* Get summary of test results
*/
getSummary(): {
total: number;
passed: number;
failed: number;
duration: number;
failures: Array<{
scenario: string;
error: string;
}>;
};
/**
* Print test results to console
*/
printResults(): void;
/**
* Reset results
*/
reset(): void;
private withTimeout;
private detectRuntime;
}
/**
* Create and run a test scenario
*/
declare function runTest(nameOrConfig: string | (TesterConfig & {
scenarios?: TestScenario[];
}), config?: TesterConfig, steps?: TestStep[], options?: TestRunnerOptions): Promise<TestResult | {
passed: number;
failed: number;
scenarios: TestResult[];
}>;
/**
* Create a test step
*/
declare function step(name: string, action: (tester: TerminalTester) => Promise<void>, assertion?: (tester: TerminalTester) => Promise<void>): TestStep;
/**
* Create a test scenario
*/
declare function scenario(name: string, steps: TestStep[], options?: {
setup?: () => Promise<void>;
teardown?: () => Promise<void>;
}): TestScenario;
export { TestRunner, type TestRunnerOptions, runTest, scenario, step };