import { MockReadable, MockWritable } from '../test/utils'; import process from 'node:process'; import type { CLI } from './CLI'; /** * Creates a test instance of a CLI application, enabling isolated testing without side effects. */ export declare function createTestCLI(options?: Record): CLI; /** * Prepares a CLI instance for testing by disabling process exits and redirecting outputs. */ export declare function setupTest(): TestContext; /** * Restore the process state after testing */ export declare function teardownTest(context: TestContext): void; /** * Executes a command on the CLI instance and returns the result. */ export declare function execCommand(cliInstance: CLI, argv: string[], options?: ExecCommandOptions): Promise; /** * Mocks user responses to interactive prompts. */ export declare function mockPrompt(responses: PromptResponses): void; /** * Gets the mocked response for a prompt if available */ export declare function getMockResponse(prompt: string): any; /** * Reset mock prompt responses */ export declare function resetMockPrompts(): void; /** * Captures all output during test execution. */ export declare function captureOutput(): { stdout: string[] stderr: string[] stop: () => { stdout: string, stderr: string } }; /** * Gets the most recent output from the test CLI. */ export declare function getLastOutput(): string; /** * Creates a temporary test directory with the specified file structure. */ export declare function createTestFS(structure: Record): Promise; /** * Cleans up the test directory. */ export declare function cleanupTestFS(testDir: string): Promise; /** * Assertion helpers for command testing * @defaultValue * ```ts * { * outputToContain: (result: ExecCommandResult, expected: string) => void, * outputToMatch: (result: ExecCommandResult, pattern: RegExp) => void, * exitCode: (result: ExecCommandResult, expected: number) => void, * completedWithin: (result: ExecCommandResult, maxDuration: number) => void, * outputNotToContain: (result: ExecCommandResult, unexpected: string) => void, * stderrToContain: (result: ExecCommandResult, expected: string) => void * } * ``` */ export declare const expect: { /** * Assert that output contains a specific string */ outputToContain: (result: ExecCommandResult, expected: string) => void; /** * Assert that output matches a regex pattern */ outputToMatch: (result: ExecCommandResult, pattern: RegExp) => void; /** * Assert that command exited with specific code */ exitCode: (result: ExecCommandResult, expected: number) => void; /** * Assert that command completed within time limit */ completedWithin: (result: ExecCommandResult, maxDuration: number) => void; /** * Assert that output does not contain a string */ outputNotToContain: (result: ExecCommandResult, unexpected: string) => void; /** * Assert that stderr contains an error message */ stderrToContain: (result: ExecCommandResult, expected: string) => void }; export declare interface TestContext { stdout: MockWritable stderr: MockWritable stdin: MockReadable originalExit: typeof process.exit originalStdout: typeof process.stdout originalStderr: typeof process.stderr originalStdin: typeof process.stdin originalConsoleLog: typeof console.log } export declare interface ExecCommandOptions { inputs?: string[] env?: Record cwd?: string timeout?: number } export declare interface ExecCommandResult { stdout: string stderr: string exitCode: number duration: number outputs: string[] result: any } /** * Response map for mocking prompts */ export type PromptResponses = Record;