# cli-testing-library

> Simple and complete CLI testing utilities that encourage good testing practices.

Latest version **4.0.0** (published 2026-08-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install cli-testing-library
pnpm add cli-testing-library
yarn add cli-testing-library
bun add cli-testing-library
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; recently updated; high maintenance score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 4.0.0 |
| Published | 2026-08-11 |
| First published | 2021-09-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | ^22.18.0 \|\| >=24.11.0 |
| Dependencies | 7 |
| Unpacked size | 203 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 137 |
| Author | Corbin Crutchley <crutchcorn@gmail.com> (https://crutchcorn.dev) |
| Maintainers | crutchcorn |
| Keywords | testing, cli, unit, integration, functional, end-to-end, e2e |

## Links

- npm: https://www.npmjs.com/package/cli-testing-library
- Repository: https://github.com/crutchcorn/cli-testing-library
- Homepage: https://github.com/crutchcorn/cli-testing-library#readme
- Issues: https://github.com/crutchcorn/cli-testing-library/issues
- Funding: https://github.com/sponsors/crutchcorn
- npm.io page: https://npm.io/package/cli-testing-library

## Dependencies (7)

- [redent](https://npm.io/package/redent.md) ^4.0.0
- [tree-kill](https://npm.io/package/tree-kill.md) ^1.2.2
- [picocolors](https://npm.io/package/picocolors.md) ^1.1.1
- [slice-ansi](https://npm.io/package/slice-ansi.md) ^9.0.0
- [strip-ansi](https://npm.io/package/strip-ansi.md) ^7.2.0
- [@babel/code-frame](https://npm.io/package/@babel/code-frame.md) ^8.0.0
- [strip-final-newline](https://npm.io/package/strip-final-newline.md) ^4.0.0

## Alternatives

- [duck](https://npm.io/package/duck.md) — 4.2M weekly downloads
- [ava](https://npm.io/package/ava.md) — 560.2K weekly downloads
- [storybook-addon-module-mock](https://npm.io/package/storybook-addon-module-mock.md) — 71.7K weekly downloads
- [@ethereum-waffle/mock-contract](https://npm.io/package/@ethereum-waffle/mock-contract.md) — 40.0K weekly downloads
- [aws-elasticsearch-connector](https://npm.io/package/aws-elasticsearch-connector.md) — 37.4K weekly downloads

## Recent versions

- 4.0.0 (latest) — 2026-08-11
- 1.0.0-alpha.17 (alpha) — 2021-12-14
- 3.0.1 — 2025-01-26
- 2.0.2 — 2024-01-02
- 2.0.1 — 2023-02-20
- 2.0.0 — 2022-06-30
- 1.0.4 — 2022-06-01
- 1.0.3 — 2022-06-01
- 1.0.2 — 2022-03-24
- 1.0.1 — 2021-12-14
- 1.0.0-alpha.16 — 2021-12-13
- 1.0.0-alpha.15 — 2021-12-13
- 1.0.0-alpha.14 — 2021-12-13
- 1.0.0-alpha.13 — 2021-12-13
- 1.0.0-alpha.12 — 2021-12-09
- … 26 more at https://npm.io/package/cli-testing-library/versions

## README

<div align="center">
<h1>CLI Testing Library</h1>

<a href="https://www.joypixels.com/profiles/emoji/1f428">
  <img
    height="80"
    width="80"
    alt="koala"
    src="https://raw.githubusercontent.com/crutchcorn/cli-testing-library/refs/heads/main/media/koala.png"
  />
</a>

<p>Simple and complete CLI testing utilities that encourage good testing
practices.</p>

</div>

<hr />

[![Build Status](https://img.shields.io/github/actions/workflow/status/crutchcorn/cli-testing-library/ci.yml?branch=main&style=flat-square)](https://github.com/crutchcorn/cli-testing-library/actions/workflows/validate.yml?query=branch%3Amain)
[![version](https://img.shields.io/npm/v/cli-testing-library?style=flat-square)](https://www.npmjs.com/package/cli-testing-library)
[![downloads](https://img.shields.io/npm/dw/cli-testing-library?style=flat-square)](https://www.npmjs.com/package/cli-testing-library)
[![MIT License](https://img.shields.io/npm/l/cli-testing-library?style=flat-square)](./LICENSE)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](makeapullrequest.com)
[![Code of Conduct](https://img.shields.io/badge/code%20of-conduct-ff69b4.svg?style=flat-square)](./CODE_OF_CONDUCT.md)
[![Watch on GitHub](https://img.shields.io/github/watchers/crutchcorn/cli-testing-library.svg?style=social)](https://github.com/crutchcorn/cli-testing-library/watchers)
[![Star on GitHub](https://img.shields.io/github/stars/crutchcorn/cli-testing-library.svg?style=social)](https://github.com/crutchcorn/cli-testing-library/stargazers)

<!-- prettier-ignore-end -->

## Table of Contents

<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->

- [Installation](#installation)
- [Usage](#usage)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

> This project is not affiliated with the
> ["Testing Library"](https://github.com/testing-library) ecosystem that this
> project is clearly inspired from. We're just big fans :)

## Installation

This module is distributed via [npm][npm] which is bundled with [node][node] and
should be installed as one of your project's `devDependencies`:

```
npm install --save-dev cli-testing-library
```

## Usage

> This is currently the only section of "usage" documentation. We'll be
> expanding it as soon as possible

Usage example:

```javascript
const { resolve } = require("path");
const { render } = require("cli-testing-library");

test("Is able to make terminal input and view in-progress stdout", async () => {
  const { clear, findByText, queryByText, userEvent } = await render("node", [
    resolve(__dirname, "./execute-scripts/stdio-inquirer.js"),
  ]);

  const instance = await findByText("First option");

  expect(instance).toBeInTheConsole();

  expect(await findByText("❯ One")).toBeInTheConsole();

  clear();

  userEvent("[ArrowDown]");

  expect(await findByText("❯ Two")).toBeInTheConsole();

  clear();

  userEvent.keyboard("[Enter]");

  expect(await findByText("First option: Two")).toBeInTheConsole();
  expect(await queryByText("First option: Three")).not.toBeInTheConsole();
});
```

For a API reference documentation, including suggestions on how to use this
library, see our
[documentation introduction with further reading](https://cli-testing.com/guides/introduction/).

> While this library _does_ work in Windows, it does not appear to function
> properly in Windows CI environments, such as GitHub actions. As a result, you
> may need to either switch CI systems or limit your CI to only run in Linux
>
> If you know how to fix this, please let us know in
> [this tracking issue](https://github.com/crutchcorn/cli-testing-library/issues/3)

---
_Source: https://npm.io/package/cli-testing-library · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
