@oclif/test

  • Version 4.0.9
  • Published
  • 12.8 kB
  • 2 dependencies
  • MIT license

Install

npm i @oclif/test
yarn add @oclif/test
pnpm add @oclif/test

Overview

test helpers for oclif components

Index

Functions

function captureOutput

captureOutput: <T>(
fn: () => Promise<unknown>,
opts?: CaptureOptions
) => Promise<CaptureResult<T>>;
  • Capture the stderr and stdout output of a function

    Parameter fn

    async function to run

    Parameter opts

    options - print: Whether to print the output to the console - stripAnsi: Whether to strip ANSI codes from the output

    Returns

    {Promise<CaptureResult>} Captured output - error: Error object if the function throws an error - result: Result of the function if it returns a value and succeeds - stderr: Captured stderr output - stdout: Captured stdout output

function runCommand

runCommand: <T>(
args: string | string[],
loadOpts?: Interfaces.LoadOptions,
captureOpts?: CaptureOptions
) => Promise<CaptureResult<T>>;
  • Capture the stderr and stdout output of a command in your CLI

    Parameter args

    Command arguments, e.g. ['my:command', '--flag'] or 'my:command --flag'

    Parameter loadOpts

    options for loading oclif Config

    Parameter captureOpts

    options for capturing the output - print: Whether to print the output to the console - stripAnsi: Whether to strip ANSI codes from the output

    Returns

    {Promise<CaptureResult>} Captured output - error: Error object if the command throws an error - result: Result of the command if it returns a value and succeeds - stderr: Captured stderr output - stdout: Captured stdout output

function runHook

runHook: <T>(
hook: string,
options: Record<string, unknown>,
loadOpts?: Interfaces.LoadOptions,
captureOpts?: CaptureOptions
) => Promise<CaptureResult<T>>;
  • Capture the stderr and stdout output of a hook in your CLI

    Parameter hook

    Hook name

    Parameter options

    options to pass to the hook

    Parameter loadOpts

    options for loading oclif Config

    Parameter captureOpts

    options for capturing the output - print: Whether to print the output to the console - stripAnsi: Whether to strip ANSI codes from the output

    Returns

    {Promise<CaptureResult>} Captured output - error: Error object if the hook throws an error - result: Result of the hook if it returns a value and succeeds - stderr: Captured stderr output - stdout: Captured stdout output

Package Files (1)

Dependencies (2)

Dev Dependencies (20)

Peer Dependencies (1)

Badge

To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@oclif/test.

  • Markdown
    [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@oclif/test)
  • HTML
    <a href="https://www.jsdocs.io/package/@oclif/test"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>