TestAdapterOptions
Options for creating a test adapter.
All fields are optional — sensible defaults are applied for testing scenarios (empty argv, empty env, noop stdout/stderr, non-TTY, exit throws instead of killing the process).
- Import:
@kjanat/dreamcli/testkit - Export kind: interface
- Declared in:
src/runtime/adapter.ts - Source link:
packages/dreamcli/src/runtime/adapter.ts:134
Signatures
interface TestAdapterOptions {}Members
Properties
argv
Raw argv (defaults to ['node', 'test']).
argv?: readonly string[];configDir
Config directory (defaults to '/home/test/.config').
configDir?: string;cwd
Working directory (defaults to '/test').
cwd?: string;env
Environment variables (defaults to {}).
env?: Readonly<Record<string, string | undefined>>;exit
Exit function (defaults to throwing ExitError). The default throw-based exit allows tests to catch the exit code.
exit?: { (code: number): never; };homedir
Home directory (defaults to '/home/test').
homedir?: string;isTTY
TTY flag for stdout (defaults to false).
isTTY?: boolean;readFile
File reader stub (defaults to returning null — all files not found).
Supply a custom function to simulate a virtual filesystem in tests:
createTestAdapter({
readFile: (path) => Promise.resolve(
path === '/home/test/.config/myapp/config.json'
? '{"region":"eu"}'
: null
),
})readFile?: { (path: string): Promise<string | null>; };stderr
Stderr writer (defaults to noop).
stderr?: WriteFn;stdin
Stdin line reader (defaults to returning null — immediate EOF).
Use a custom ReadFn to simulate user input in tests.
stdin?: ReadFn;stdinData
Piped stdin data for testing args with .stdin() configured.
When provided and stdinIsTTY is false, readStdin() returns this string once, then null on subsequent reads. When absent, or when stdinIsTTY is true, readStdin() returns null.
stdinData?: string;stdinIsTTY
TTY flag for stdin (defaults to false).
stdinIsTTY?: boolean;stdout
Stdout writer (defaults to noop).
stdout?: WriteFn;