Skip to main content

runProgram

Callable

  • runProgram(program: Program, argv: string[], options?: { append?: boolean }): Promise<{ code: ExitCode; output: string; outputStripped: string }>

  • Runs a Program as if it were ran on the command line, including middleware, commands, success and failure states, and more. Utilizes mocked streams to capture and return standard output and ANSI stripped output. Failed runs will not throw and instead will render a failure output.

    import { runProgram } from '@boost/cli/test';
    import Program from '../src/program';

    it('runs a program', async () => {
    const program = new Program();

    const { code, output } = await runProgram(program, ['cmd', '--foo', '123', 'bar']);

    expect(output).toMatchSnapshot();
    expect(code).toBe(0);
    });