@oclif/test
TypeScript icon, indicating that this package has built-in type declarations

4.0.1 • Public • Published

@oclif/test

test helpers for oclif CLIs

Version Downloads/week License

Migration

See the V4 Migration Guide if you are migrating from v3 or older.

Usage

@oclif/test provides a handful of utilities that make it easy to test your oclif CLI.

captureOutput

captureOutput allows you to get the stdout, stderr, return value, and error of the callback you provide it. This makes it possible to assert that certain strings were printed to stdout and stderr or that the callback failed with the expected error or succeeded with the expected result.

Options

  • print - Print everything that goes to stdout and stderr.
  • stripAnsi - Strip ansi codes from everything that goes to stdout and stderr. Defaults to true.

See the tests for example usage.

runCommand

runCommand allows you to get the stdout, stderr, return value, and error of a command in your CLI.

See the tests for example usage.

runHook

runHook allows you to get the stdout, stderr, return value, and error of a hook in your CLI.

See the tests for example usage.

Readme

Keywords

Package Sidebar

Install

npm i @oclif/test

Weekly Downloads

202,067

Version

4.0.1

License

MIT

Unpacked Size

12.3 kB

Total Files

5

Last publish

Collaborators

  • anycli-bot
  • mdonnalley
  • salesforce-releases