Skip to main content

runTask

Callable

  • runTask<A, R, T>(task: (this: T, ...argz: A) => R, args: A, context?: Partial<T>): Promise<R>

  • Runs a task function outside the context of a Command, in complete isolation. A mock command context is provided with standard defaults, and can be customized through the 3rd argument.

    import { runTask } from '@boost/cli/test';
    import testTask from '../src/tasks/testTask';

    it('runs a task', async () => {
    const context = {
    log: vi.fn(),
    };

    expect(await runTask(testTask, ['foo', 'bar', 'baz'], context)).toMatchSnapshot();
    expect(context.log).toHaveBeenCalled();
    });

    Type parameters